-
Notifications
You must be signed in to change notification settings - Fork 62
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
Import fails after Jest v28 update (Cannot use import statement outside a module) #198
Comments
I hit the same issue. I believe something like #243 would fix the root cause but has been closed. As a workaround (not ideal) you can mock out
Then in your
Note this means that I think there may be a better way to fix this like Ideally |
Yeah I mean if folks want to submit a PR to better support jest, I'm all for it! I just don't really use this package or jest at this point, so it's unlikely something that I'll dig into. |
Hi @JustinBeckwith - thank you for your response and for your work on this package. From what I understand, the linked PR #243 would fix this for jest, as by default jest assumes that packages in |
.... seriously!? I obviously want to make sure folks can test with this library, but again - CommonJS is a step backwards and not something we should be trying to support (in the general) sense. I won't go an ESM rant here, but I find it super hard to believe Jest wouldn't be able to support ESM 😆 |
I believe there's a way to override the default Jest behaviour with |
jest support for ESM is experimental, and you must run node with |
I've been having trouble with imports failing when running tests on the file that has
retry-axios
imported.This error only appears when running tests with jest ever since jest v28 update.
I get no errors when building or running the project.
` FAIL tests/core/HttpClient.spec.ts
● Test suite failed to run
Test Suites: 1 failed, 3 passed, 4 total
Tests: 9 passed, 9 total
Snapshots: 0 total
Time: 9.129 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`
I tried using a resolver similar to the one used here microsoft/accessibility-insights-web@9ad4e61 but it didn't work.
jest.config.json file
babel.config.ts file
tsconfig.spec.json
The text was updated successfully, but these errors were encountered: