Skip to content

[Bug]: jest.config.ts parsing broken on node 24 + CJS #15682

Description

@Marsup

Version

30.0.0

Steps to reproduce

Apparently, typescript configuration file parsing is broken in jest 30 when used in a module that is still configured in CJS because it's now relying on node to do the parsing. Since node is only about type stripping, if you are still part of the unlucky crowd that hasn't managed to make the jump to ESM, you'll get this:

Error: Jest: Failed to parse the TypeScript config file ./jest.config.ts
  SyntaxError: Cannot use import statement outside a module

I traced it back to #15480.

My current workaround is to always have --no-experimental-strip-types set, but it's not ideal.

Expected behavior

I think it should only use node's parser if process.features.typescript is on, and the module is in ESM, but that last part seems tricky.

Actual behavior

It crashes.

Additional context

No response

Environment

System:
    OS: Linux 6.14 Ubuntu 25.04 25.04 (Plucky Puffin)
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
  Binaries:
    Node: 24.2.0
    npm: 11.3.0
    pnpm: 9.15.5
  npmPackages:
    jest: ^30.0.0 => 30.0.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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