You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jest encountered an unexpected token
Jest failed to parse a file. [...]
Details:
/home/dan/prg/got-jest/node_modules/got/dist/source/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import create from './create.js';
^^^^^^
SyntaxError: Cannot use import statement outside a module
> 1 | import got from 'got';
| ^
2 |
3 | /* Commented out due to bogus error
4 | * error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
at Object.<anonymous> (index.ts:1:1)
at Object.<anonymous> (index.test.ts:1:1)
Version
29.1.1
Steps to reproduce
git clone https://github.com/dandv/got-jest && cd got-jest
npm install
node --loader ts-node/esm index.test.ts
// correct error,ReferenceError: test is not defined
, shows the ts-node setup worksnpm test
Expected behavior
I expect the test to pass.
Actual behavior
FAIL ./index.test.ts
● Test suite failed to run
Debug log
ts-jest.log
Additional context
If I comment out the
await got
call fromfoo()
and the console.log line that follows, the test passes, showing the ts-jest setup is correct.I tried this configuration with
babel-jest
but it still failed.Environment
The text was updated successfully, but these errors were encountered: