jest
jest copied to clipboard
Compile typescript from child_process fork does not work (dynamic import)
I have typescript fork(filename) from node:child_process. When i try to run tests, I have an error Unknown file extension ".ts" for /[...myfullpath]/getSpots.ts. All imports works good but import file via fork for multithreading
jest.config.ts
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts'],
testEnvironment: 'node',
transform: {
'.*\\.(tsx?)$': ['@swc/jest', {
jsc: {
target: "es2021",
parser: {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
},
}],
},
testRegex: [
'/tests/.*\\.(test|spec)\\.(ts)$',
'/src/.*\\.(test|spec)\\.(ts)$',
],
transformIgnorePatterns: [
'node_modules',
'./dist',
],
testPathIgnorePatterns: ['./dist'],
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
testTimeout: 240 * 1_000,
};
export default config;
It also doesnt work with node:worker_threads