-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
SyntaxError: Unexpected token 'export'
when using Jest
#1796
Comments
I also face similar problems using Ex.
Not sure if this is expected, but I needed to add the following in deps: {
inline: ['next-intl'],
}, |
Somehow the Jest examples in this repo still worked, but if you try to use `next-intl` outside of this monorepo there was an issue with Jest. The problem is that Jest doesn't support ESM (see e.g. vercel/next.js#40183). Ref #1796
@ClementDreptin Thank you for raising this issue! Somehow the Jest examples in this repo still worked, but I can confirm that usage outside of this repo needed an adjustment. I've now updated the examples in this repo. @service-paradis Also many thanks for your comment! I've now added new testing docs that address both issues raised in this thread and have also linked to this page from the release notes. Thanks again for sharing your findings and sorry for the trouble! I hope that in a future where vercel/next.js#77200 is fixed and tools like Jest support ESM natively, we can get rid of these workarounds that are necessary for the time being! |
Thank you for your work on this package and for the follow-up! |
Thank you very much for the very quick fix! |
Description
Since the recent move of
next-intl
to ESM, running tests with Jest broke.Verifications
Mandatory reproduction URL
https://github.com/amannn/next-intl/tree/main/examples/example-app-router
Reproduction description
example-app-router
example app.test:jest
script that is inpackage.json
.Expected behaviour
I expect Jest to run the tests successfully.
What I tried
I feel like I tested just about every configuration combination possible in
tsconfig.json
andjest.config.ts
and followed the Jest docs about using ES modules, to no avail.I noticed that in #1470 the first breaking change mentioned is
but I'm not sure what you mean by "Jest might benefit from
next/jest
", this is probably where I missed something.The text was updated successfully, but these errors were encountered: