Skip to content

v7 fails in Jest, v6 works ok #1323

@mataspetrikas

Description

@mataspetrikas

Screenshot

Image

Description

We have a Next.js TypeScript setup, using graphql-request v6.1.0, trying to update to v7.1.2

The app integration works ok, with no code changes. But - when running the unit tests, if a test imports any code that depends on the graphql-request, the jest fails with a following message:

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

...

    SyntaxError: Cannot use import statement outside a module
...

Did anyone encounter that error already? Any changes that can be added to jest.config maybe?
I have tried adding the library path to transformIgnorePatterns but that didn't help.

Downgrading back to v6 resolves it but I'd rather update to latest.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions