-
Notifications
You must be signed in to change notification settings - Fork 453
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
[Bug]: Using "module": "NodeNext" causes the error "SyntaxError: Cannot use import statement outside a module" #4464
Comments
I think I know the issue. Since we allow the usage of There are 2 ways to workaround your issue:
Hi @SimenB @mrazauskas can Jest automatically pick up |
I can confirm that changing to For a bit more context, I'm using tshy which is fairly opinionated and generates code using |
Actually before the fix, After the fix, we take into account of If we revert back, the support for these 2 module values won’t be possible. Ideally, Jest should be able to run in ESM mode when it sees On a side note, I saw your example repo uses ESM preset but the script to run test is without I don’t think it’s possible for us to fix this issue. We highly depend on what Jest wants to accept. |
I see, this is all starting to make more sense. I didn't realize that the Updating the test script in my example to I appreciate your time looking into this! I think it's okay to close this issue. |
Thanks! |
Version
29.2.1+
Steps to reproduce
yarn test
and see the errorts-jest
to the latest (currently 29.2.3), then runyarn test
and see the errorts-jest
to 29.2.0, then runyarn test
and tests should passExpected behavior
Tests should pass
Actual behavior
The test suite fails to run
Debug log
ts-jest.log
Additional context
Appears to be very similar to #4439
Environment
The text was updated successfully, but these errors were encountered: