Skip to content

SyntaxError: Unexpected token 'export' when using Jest #1796

Closed
@ClementDreptin

Description

@ClementDreptin

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

  1. Clone the example-app-router example app.
  2. Run the test:jest script that is in package.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 and jest.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

The CommonJS build has been removed. While most tools support ESM out-of-the-box, some might require additional configuration (e.g. Jest might benefit from next/jest).

but I'm not sure what you mean by "Jest might benefit from next/jest", this is probably where I missed something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingunconfirmedNeeds triage.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions