jest icon indicating copy to clipboard operation
jest copied to clipboard

feat(jest-config): supports Jest config file with `.mts` extension

Open hainenber opened this issue 3 months ago • 8 comments

Summary

Resolves #15780

This PR will allow .mts config file to be passed to Jest, enabling folks to work with native type stripping in CommonJS projects. However, full .mts support is only for Node 23.6 and above due to type stripping enabled by default. On Node version ^20.19.0 || ^22.12.0, untyped jest.config.mts would still be accepted by Jest but adding type would emit error.

Test plan

hainenber avatar Aug 24 '25 16:08 hainenber

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
Latest commit 15c06e3e1db9361df27d698812070ecb45b4ebf5
Latest deploy log https://app.netlify.com/projects/jestjs/deploys/68fe46ae6c0082000929e78c
Deploy Preview https://deploy-preview-15796--jestjs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Aug 24 '25 16:08 netlify[bot]

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15796
babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15796
babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15796
create-jest

npm i https://pkg.pr.new/create-jest@15796
@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15796
expect

npm i https://pkg.pr.new/expect@15796
@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15796
jest

npm i https://pkg.pr.new/jest@15796
jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15796
jest-circus

npm i https://pkg.pr.new/jest-circus@15796
jest-cli

npm i https://pkg.pr.new/jest-cli@15796
jest-config

npm i https://pkg.pr.new/jest-config@15796
@jest/console

npm i https://pkg.pr.new/@jest/console@15796
@jest/core

npm i https://pkg.pr.new/@jest/core@15796
@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15796
jest-diff

npm i https://pkg.pr.new/jest-diff@15796
jest-docblock

npm i https://pkg.pr.new/jest-docblock@15796
jest-each

npm i https://pkg.pr.new/jest-each@15796
@jest/environment

npm i https://pkg.pr.new/@jest/environment@15796
jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15796
@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15796
jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15796
@jest/expect

npm i https://pkg.pr.new/@jest/expect@15796
@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15796
@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15796
@jest/globals

npm i https://pkg.pr.new/@jest/globals@15796
jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15796
jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15796
jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15796
jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15796
jest-message-util

npm i https://pkg.pr.new/jest-message-util@15796
jest-mock

npm i https://pkg.pr.new/jest-mock@15796
@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15796
jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15796
jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15796
@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15796
jest-resolve

npm i https://pkg.pr.new/jest-resolve@15796
jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15796
jest-runner

npm i https://pkg.pr.new/jest-runner@15796
jest-runtime

npm i https://pkg.pr.new/jest-runtime@15796
@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15796
jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15796
@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15796
@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15796
@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15796
@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15796
@jest/transform

npm i https://pkg.pr.new/@jest/transform@15796
@jest/types

npm i https://pkg.pr.new/@jest/types@15796
jest-util

npm i https://pkg.pr.new/jest-util@15796
jest-validate

npm i https://pkg.pr.new/jest-validate@15796
jest-watcher

npm i https://pkg.pr.new/jest-watcher@15796
jest-worker

npm i https://pkg.pr.new/jest-worker@15796
pretty-format

npm i https://pkg.pr.new/pretty-format@15796

commit: 15c06e3

pkg-pr-new[bot] avatar Aug 24 '25 16:08 pkg-pr-new[bot]

@hainenber type stripping is also enabled by default in node 22 since version 22.18.0 (see https://nodejs.org/en/blog/release/v22.18.0)

fidgi avatar Sep 02 '25 10:09 fidgi

Hi can we get this to merge? Is it changing to .mts would help us to get through Node 22.18 strip type enabling?

ahnpnl avatar Sep 17 '25 18:09 ahnpnl

Seems like the CI is still failing on these. Might need to disable them on older Node versions.

cpojer avatar Sep 28 '25 07:09 cpojer

CI is failing on multiple node versions, so I don't think the version itself is the issue. Looks like a regression?

(would love to land this 😀)

SimenB avatar Oct 10 '25 18:10 SimenB

PR adjusted to be JS runtime agnostic, thanks to @ashleybartlett's suggestion.

Jest should understand require(esm) and type stripping based on the JS runtime's feature flag values of process.feature.require_module and process.feature.typescript; folks can use NODE_OPTIONS to toggle on or off on demand.

Hopefully CI gods let me through.

hainenber avatar Oct 15 '25 15:10 hainenber

any ETA for this to be merged?

Stanzilla avatar Nov 24 '25 22:11 Stanzilla