-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Open
Labels
Description
Version
30.2.0
Steps to reproduce
- create a simple repo with this
package.json:
{
"name": "test-jest",
"version": "1.0.0",
"devDependencies": {
"@swc/jest": "^0.2.39",
"@types/jest": "^30.0.0",
"jest": "^30.2.0",
"ts-node": "^10.9.2"
}
}- create a simple
jest.config.ctsfile:
import type { Config } from 'jest';
const config: Config = {
rootDir: __dirname,
testMatch: ['<rootDir>/__tests__/**/*.test.(js|ts)'],
transform: {
'\\.(ts|js)$': '@swc/jest',
},
};
// eslint-disable-next-line import/no-default-export
export default config;- create a simple
__tests__/foo.test.tsfile:
describe('foo', () => {
it('should pass this test', () => {
expect(true).toBe(true);
});
});- run
npx jest
Expected behavior
No warnings
Actual behavior
A warning appears in the console:
(node:81672) Warning: Failed to load the ES module: /(...)/jest.config.cts. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
This does not prevent the tests from running properly. Afaik we should not need to add "type": "module" when naming the config file using the cts extension.
Note that the warning is absent when using the mts extension.
Additional context
No response
Environment
System:
OS: macOS 15.7.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 24.11.0 - /Users/jeromelouis/.nvm/versions/node/v24.11.0/bin/node
Yarn: 1.22.22 - /Users/jeromelouis/.nvm/versions/node/v22.11.0/bin/yarn
npm: 11.6.1 - /Users/jeromelouis/.nvm/versions/node/v24.11.0/bin/npm
pnpm: 10.14.0 - /Users/jeromelouis/.nvm/versions/node/v22.11.0/bin/pnpm
npmPackages:
jest: ^30.2.0 => 30.2.0