Skip to content

[Bug]: loading jest.config.ts results in "Unexpected token 'export'" #15797

@lppedd

Description

@lppedd

Version

30.0.5

Steps to reproduce

This is a follow up to #15682, since that one is closed.
As far as I understand, an attempt to fix the problem was made in #15694.

Under Node.js 22.18, loading a jest.config.ts with ESM syntax under CommonJS results in the following error:

Image

And this Node.js warning:

Warning: Failed to load the ES module: C:\Users\edoardo.luppi\IdeaProjects\client-vscode\client-shared\ts\jest.config.ts. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension


This is the code flow for the code path that was changed in #15694 and #15720.

jest-debug.mp4

Expected behavior

It should load the TS file without erroring out.

Actual behavior

It throws an error.

Can be workarounded by using --no-experimental-strip-types.

Additional context

No response

Environment

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
  Node: 22.18.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
  npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
  pnpm: 9.5.0 - ~\AppData\Roaming\npm\pnpm.CMD
npmPackages:
  jest: 29.7.0 => 29.7.0

Note that the Jest code I'm debugging is from 30.0.5, even tho I currently have 29.7.0 mentioned in my package.json file.

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