-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Native ESM] [ts-jest@next] ReferenceError: exports is not defined #2399
Comments
Hi, would you please check with Jest repo. IIRC export is not supported yet. We only transpile ts to js and Jest runs the transpires codes so I don’t think this is |
See more at jestjs/jest#9430 |
@ahnpnl Yes, I was experimenting with the native ESM support mentioned in jestjs/jest#9430, and by your comment there I thought it's being implemented in ts-jest@next. Is my understanding wrong, or shouldn't have I filed ts-jest@next's issue here? |
A similar configuration works with babel-jest@next so I thought it's ts-jest@next's issue |
I see you missed one important thing, enable support esm config option for ts-jest. If you go to online doc and choose next version, you will find the guide :) |
Aaah, this one! https://kulshekhar.github.io/ts-jest/docs/next/guides/esm-support Thanks! It turned out to be my mistake. |
🐛 Bug Report
Under a certain condition with native ESM support, the test fails with
ReferenceError: exports is not defined
.To Reproduce
package.json:
lib.ts:
lib.test.ts:
tsconfig.json:
And without
--no-cache
, the following behaviors are observed:lib.ts
a bit (e.g. adding / removing empty lines) and rerun the test: the test starts to fail.lib.test.ts
a bit (e.g. adding / removing empty lines) and rerun the test: the test starts to pass.Expected behavior
The test is expected to always pass.
Link to repo (highly encouraged)
https://github.com/qnighy/ts-jest-esm-failure-example
The example above was extracted from https://github.com/qnighy/ts-type-module-example.
Debug log:
https://gist.github.com/qnighy/9ba2c6b2023c4a8dad38c53faf4ed592
envinfo
The text was updated successfully, but these errors were encountered: