Skip to content

Commit 954c7c8

Browse files
committed
fix: add Jest docblock pragma for ts-node compatibility
Add @jest-config-loader-options docblock pragma to Jest config files that import other .ts files. This ensures ts-node compiles these files with allowImportingTsExtensions enabled, which is required for .ts extension imports to work. The issue occurs because Jest v30 uses ts-node to compile TypeScript config files, and ts-node registers with module: 'CommonJS' by default, which doesn't allow .ts extensions in imports. The docblock pragma passes compiler options to ts-node, enabling the required setting. This fix ensures compatibility across all Node 22.x versions, including versions prior to 22.18.0 which don't have native TypeScript support. Tested with Node 22.17.1 and 22.20.0.
1 parent 8836ab4 commit 954c7c8

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

jest.config.all.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @jest-config-loader-options {"compilerOptions":{"allowImportingTsExtensions":true}}
3+
*/
14
import type { Config } from 'jest';
25
import baseConfig from './jest.config.ts';
36

jest.config.mutation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @jest-config-loader-options {"compilerOptions":{"allowImportingTsExtensions":true}}
3+
*/
14
import type { Config } from 'jest';
25
import baseConfig from './jest.config.ts';
36

jest.config.private.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @jest-config-loader-options {"compilerOptions":{"allowImportingTsExtensions":true}}
3+
*/
14
import type { Config } from 'jest';
25
import baseConfig from './jest.config.ts';
36

0 commit comments

Comments
 (0)