[Bug]: import.meta.url doesn't work
EphraimB opened this issue · 5 comments
EphraimB commented
Version
29.1.1
Steps to reproduce
- Clone at https://github.com/EphraimB/budgeting and use the ts-jest branch
- npm install
- npm run test -- app.test.ts
- Test fails without an error message
Expected behavior
I expect the test to pass
Actual behavior
Test fails without an error message
Debug log
Additional context
The production code runs. It's just the test that passes.
Environment
System:
OS: macOS 13.4.1
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Binaries:
Node: 18.13.0 - /usr/local/bin/node
npm: 8.19.3 - /usr/local/bin/npm
npmPackages:
jest: ^29.6.1 => 29.6.1
BinToss commented
Deciphered from your log:
app.ts: 21:46 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
21 const __dirname = fileURLToPath(new URL('.', import.meta.url));
~~~~~~~~~~~
app.ts:31:1 - 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.
31 await initializeBree();
~~~~~
I've noticed TypeScript errors aren't being formatted and printed to the console when run by ts-jest.
ckrauterlovescoffee commented
Any updates on this?
ahnpnl commented
Hi @EphraimB @ckrauterlovescoffee do you still experience the issue? Are you running Jest in ESM mode?
EphraimB commented
I'm migrating my code away from express to NestJS so this issue doesn't affect me anymore.
ahnpnl commented
i will close this issue for now. If anyone still experiences the issue with latest version, pls feel free to open another issue.