diff --git a/e2e/const-enum/__tests__/const-enum.spec.ts b/e2e/const-enum/__tests__/const-enum.spec.ts index 14a5a95adf..c14c81d12b 100644 --- a/e2e/const-enum/__tests__/const-enum.spec.ts +++ b/e2e/const-enum/__tests__/const-enum.spec.ts @@ -1,12 +1,9 @@ import { BarConstEnum } from '../src/bar-constant' import { FooConstEnum } from '../src/foo-constant' -const getOne = (): string => BarConstEnum.one -const getTwo = (): string => FooConstEnum.two - describe('const-enum', () => { - it('should pass', () => { - expect(getOne()).toBe('ONE') - expect(getTwo()).toBe('TWO') + it('should pass with non transpilation mode', () => { + expect(BarConstEnum.one).toBe('ONE') + expect(FooConstEnum.two).toBe('TWO') }) }) diff --git a/e2e/const-enum/jest-transpiler-cjs.config.ts b/e2e/const-enum/jest-transpiler-cjs.config.ts index 22362145ee..986e0367d6 100644 --- a/e2e/const-enum/jest-transpiler-cjs.config.ts +++ b/e2e/const-enum/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/const-enum/jest-transpiler-esm.config.ts b/e2e/const-enum/jest-transpiler-esm.config.ts index 0508cd7597..3c456c16d7 100644 --- a/e2e/const-enum/jest-transpiler-esm.config.ts +++ b/e2e/const-enum/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/const-enum/tsconfig-cjs-transpiler.spec.json b/e2e/const-enum/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index 6766745a8c..0000000000 --- a/e2e/const-enum/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true, - } -} diff --git a/e2e/const-enum/tsconfig-esm-transpiler.spec.json b/e2e/const-enum/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index e5dc0b8093..0000000000 --- a/e2e/const-enum/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true, - } -} diff --git a/e2e/enum/jest-transpiler-cjs.config.ts b/e2e/enum/jest-transpiler-cjs.config.ts index 44abf494dd..c82e35f4ac 100644 --- a/e2e/enum/jest-transpiler-cjs.config.ts +++ b/e2e/enum/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [ESM_TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/enum/jest-transpiler-esm.config.ts b/e2e/enum/jest-transpiler-esm.config.ts index 4bb9fb2339..4fe80b6a46 100644 --- a/e2e/enum/jest-transpiler-esm.config.ts +++ b/e2e/enum/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/enum/tsconfig-cjs-transpiler.spec.json b/e2e/enum/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/enum/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/enum/tsconfig-esm-transpiler.spec.json b/e2e/enum/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/enum/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/esm-features/jest-compiler-esm.config.ts b/e2e/esm-features/jest-compiler-esm.config.ts index f4d2d3a627..0f7344b195 100644 --- a/e2e/esm-features/jest-compiler-esm.config.ts +++ b/e2e/esm-features/jest-compiler-esm.config.ts @@ -7,7 +7,7 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, }, ], diff --git a/e2e/esm-features/jest-transpiler-esm.config.ts b/e2e/esm-features/jest-transpiler-esm.config.ts index ba82d0c777..85f0a36851 100644 --- a/e2e/esm-features/jest-transpiler-esm.config.ts +++ b/e2e/esm-features/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/esm-features/tsconfig-esm-transpiler.spec.json b/e2e/esm-features/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/esm-features/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/extend-ts-jest/jest-transpiler-cjs.config.ts b/e2e/extend-ts-jest/jest-transpiler-cjs.config.ts index 8bb7e0f0ff..ef4bd42ce7 100644 --- a/e2e/extend-ts-jest/jest-transpiler-cjs.config.ts +++ b/e2e/extend-ts-jest/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/extend-ts-jest/jest-transpiler-esm.config.ts b/e2e/extend-ts-jest/jest-transpiler-esm.config.ts index cb98eaf97f..1829ffeea7 100644 --- a/e2e/extend-ts-jest/jest-transpiler-esm.config.ts +++ b/e2e/extend-ts-jest/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/extend-ts-jest/tsconfig-cjs-transpiler.spec.json b/e2e/extend-ts-jest/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/extend-ts-jest/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/extend-ts-jest/tsconfig-esm-transpiler.spec.json b/e2e/extend-ts-jest/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/extend-ts-jest/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/hoist-jest/jest-transpiler-cjs.config.ts b/e2e/hoist-jest/jest-transpiler-cjs.config.ts index cde38b9095..7096973414 100644 --- a/e2e/hoist-jest/jest-transpiler-cjs.config.ts +++ b/e2e/hoist-jest/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/hoist-jest/tsconfig-cjs-transpiler.spec.json b/e2e/hoist-jest/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/hoist-jest/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/presets/jest-transpiler-cjs.config.ts b/e2e/presets/jest-transpiler-cjs.config.ts index 2d48a8e6f6..69ce9eb59d 100644 --- a/e2e/presets/jest-transpiler-cjs.config.ts +++ b/e2e/presets/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/presets/jest-transpiler-esm.config.ts b/e2e/presets/jest-transpiler-esm.config.ts index f1fadd9294..ef3510faf8 100644 --- a/e2e/presets/jest-transpiler-esm.config.ts +++ b/e2e/presets/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/presets/tsconfig-cjs-transpiler.spec.json b/e2e/presets/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/presets/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/presets/tsconfig-esm-transpiler.spec.json b/e2e/presets/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/presets/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/source-map/jest-transpiler-cjs.config.ts b/e2e/source-map/jest-transpiler-cjs.config.ts index 87a2d36448..e5d34238b6 100644 --- a/e2e/source-map/jest-transpiler-cjs.config.ts +++ b/e2e/source-map/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/../tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/source-map/jest-transpiler-esm.config.ts b/e2e/source-map/jest-transpiler-esm.config.ts index 72a0dce75b..0a14d8be96 100644 --- a/e2e/source-map/jest-transpiler-esm.config.ts +++ b/e2e/source-map/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/../tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/source-map/tsconfig-cjs-transpiler.spec.json b/e2e/source-map/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index 9fa786da18..0000000000 --- a/e2e/source-map/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/source-map/tsconfig-esm-transpiler.spec.json b/e2e/source-map/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 472d2ecaf4..0000000000 --- a/e2e/source-map/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/test-utils/jest-transpiler-cjs.config.ts b/e2e/test-utils/jest-transpiler-cjs.config.ts index c861896ec5..88abbbd915 100644 --- a/e2e/test-utils/jest-transpiler-cjs.config.ts +++ b/e2e/test-utils/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/../tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/test-utils/jest-transpiler-esm.config.ts b/e2e/test-utils/jest-transpiler-esm.config.ts index 34d1cdb47a..eb68d81660 100644 --- a/e2e/test-utils/jest-transpiler-esm.config.ts +++ b/e2e/test-utils/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/../tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/test-utils/tsconfig-cjs-transpiler.spec.json b/e2e/test-utils/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index 9fa786da18..0000000000 --- a/e2e/test-utils/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/test-utils/tsconfig-esm-transpiler.spec.json b/e2e/test-utils/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 472d2ecaf4..0000000000 --- a/e2e/test-utils/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transform-js/jest-transpiler-cjs.config.ts b/e2e/transform-js/jest-transpiler-cjs.config.ts index 47ef8c3919..51b81d1972 100644 --- a/e2e/transform-js/jest-transpiler-cjs.config.ts +++ b/e2e/transform-js/jest-transpiler-cjs.config.ts @@ -6,7 +6,8 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', + transpilation: true, }, ], }, diff --git a/e2e/transform-js/jest-transpiler-esm.config.ts b/e2e/transform-js/jest-transpiler-esm.config.ts index b1d72f1dc6..837d04b5c8 100644 --- a/e2e/transform-js/jest-transpiler-esm.config.ts +++ b/e2e/transform-js/jest-transpiler-esm.config.ts @@ -7,8 +7,9 @@ export default { [TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/transform-js/tsconfig-cjs-transpiler.spec.json b/e2e/transform-js/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/transform-js/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transform-js/tsconfig-esm-transpiler.spec.json b/e2e/transform-js/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/transform-js/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transformer-in-ts/jest-transpiler-cjs.config.ts b/e2e/transformer-in-ts/jest-transpiler-cjs.config.ts index efaadf1be1..00d146385d 100644 --- a/e2e/transformer-in-ts/jest-transpiler-cjs.config.ts +++ b/e2e/transformer-in-ts/jest-transpiler-cjs.config.ts @@ -6,7 +6,7 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/../tsconfig-cjs.spec.json', astTransformers: { before: [ { @@ -14,6 +14,7 @@ export default { }, ], }, + transpilation: true, }, ], }, diff --git a/e2e/transformer-in-ts/jest-transpiler-esm.config.ts b/e2e/transformer-in-ts/jest-transpiler-esm.config.ts index 3c4bd4e013..bb2163ffde 100644 --- a/e2e/transformer-in-ts/jest-transpiler-esm.config.ts +++ b/e2e/transformer-in-ts/jest-transpiler-esm.config.ts @@ -7,7 +7,7 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/../tsconfig-esm.spec.json', astTransformers: { before: [ { @@ -16,6 +16,7 @@ export default { ], }, useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/transformer-in-ts/tsconfig-cjs-transpiler.spec.json b/e2e/transformer-in-ts/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index 9fa786da18..0000000000 --- a/e2e/transformer-in-ts/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transformer-in-ts/tsconfig-esm-transpiler.spec.json b/e2e/transformer-in-ts/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 472d2ecaf4..0000000000 --- a/e2e/transformer-in-ts/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transformer-options/jest-transpiler-cjs.config.ts b/e2e/transformer-options/jest-transpiler-cjs.config.ts index b8bd41bace..665e8e8d37 100644 --- a/e2e/transformer-options/jest-transpiler-cjs.config.ts +++ b/e2e/transformer-options/jest-transpiler-cjs.config.ts @@ -7,7 +7,7 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-cjs-transpiler.spec.json', + tsconfig: '/tsconfig-cjs.spec.json', astTransformers: { before: [ { @@ -18,6 +18,7 @@ export default { }, ], }, + transpilation: true, }, ], }, diff --git a/e2e/transformer-options/jest-transpiler-esm.config.ts b/e2e/transformer-options/jest-transpiler-esm.config.ts index 9f5d48cba3..e5e14c5828 100644 --- a/e2e/transformer-options/jest-transpiler-esm.config.ts +++ b/e2e/transformer-options/jest-transpiler-esm.config.ts @@ -8,7 +8,7 @@ export default { [TS_TRANSFORM_PATTERN]: [ 'ts-jest', { - tsconfig: '/tsconfig-esm-transpiler.spec.json', + tsconfig: '/tsconfig-esm.spec.json', astTransformers: { before: [ { @@ -20,6 +20,7 @@ export default { ], }, useESM: true, + transpilation: true, }, ], }, diff --git a/e2e/transformer-options/tsconfig-cjs-transpiler.spec.json b/e2e/transformer-options/tsconfig-cjs-transpiler.spec.json deleted file mode 100644 index c3a5cf432c..0000000000 --- a/e2e/transformer-options/tsconfig-cjs-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-cjs.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/e2e/transformer-options/tsconfig-esm-transpiler.spec.json b/e2e/transformer-options/tsconfig-esm-transpiler.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/e2e/transformer-options/tsconfig-esm-transpiler.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/js-with-babel/jest-esm-isolated.config.ts b/examples/js-with-babel/jest-esm-transpiler.config.ts similarity index 78% rename from examples/js-with-babel/jest-esm-isolated.config.ts rename to examples/js-with-babel/jest-esm-transpiler.config.ts index fc872286a0..17f3a98c45 100644 --- a/examples/js-with-babel/jest-esm-isolated.config.ts +++ b/examples/js-with-babel/jest-esm-transpiler.config.ts @@ -5,6 +5,7 @@ export default { displayName: 'js-with-babel', ...createJsWithBabelEsmPreset({ babelConfig: true, - tsconfig: 'tsconfig-esm-isolated.json', + tsconfig: 'tsconfig-esm.json', + transpilation: true, }), } satisfies Config diff --git a/examples/js-with-babel/jest-isolated.config.ts b/examples/js-with-babel/jest-transpiler.config.ts similarity index 84% rename from examples/js-with-babel/jest-isolated.config.ts rename to examples/js-with-babel/jest-transpiler.config.ts index ea6bdb3537..b9ddca12c3 100644 --- a/examples/js-with-babel/jest-isolated.config.ts +++ b/examples/js-with-babel/jest-transpiler.config.ts @@ -5,6 +5,6 @@ export default { displayName: 'js-with-babel', ...createJsWithBabelPreset({ babelConfig: true, - tsconfig: 'tsconfig-isolated.json', + transpilation: true, }), } satisfies Config diff --git a/examples/js-with-babel/package.json b/examples/js-with-babel/package.json index bcd5f68843..4fae34a9ca 100644 --- a/examples/js-with-babel/package.json +++ b/examples/js-with-babel/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "test": "jest -c=jest.config.ts --no-cache", - "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-transpiler": "jest -c=jest-transpiler.config.ts --no-cache", "test-esm": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm.config.ts --no-cache", - "test-esm-isolated": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-isolated.config.ts --no-cache" + "test-esm-transpiler": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-transpiler.config.ts --no-cache" }, "devDependencies": { "@babel/core": "^7.28.4", diff --git a/examples/js-with-babel/tsconfig-esm-isolated.json b/examples/js-with-babel/tsconfig-esm-isolated.json deleted file mode 100644 index d3468381f7..0000000000 --- a/examples/js-with-babel/tsconfig-esm-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/js-with-babel/tsconfig-isolated.json b/examples/js-with-babel/tsconfig-isolated.json deleted file mode 100644 index 4b8f61b29f..0000000000 --- a/examples/js-with-babel/tsconfig-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/js-with-ts/jest-esm-isolated.config.ts b/examples/js-with-ts/jest-esm-transpiler.config.ts similarity index 75% rename from examples/js-with-ts/jest-esm-isolated.config.ts rename to examples/js-with-ts/jest-esm-transpiler.config.ts index 938e924259..0b72505462 100644 --- a/examples/js-with-ts/jest-esm-isolated.config.ts +++ b/examples/js-with-ts/jest-esm-transpiler.config.ts @@ -4,6 +4,7 @@ import { createJsWithTsEsmPreset } from 'ts-jest' export default { displayName: 'js-with-ts', ...createJsWithTsEsmPreset({ - tsconfig: 'tsconfig-esm-isolated.json', + tsconfig: 'tsconfig-esm.json', + transpilation: true, }), } satisfies Config diff --git a/examples/js-with-ts/jest-isolated.config.ts b/examples/js-with-ts/jest-transpiler.config.ts similarity index 85% rename from examples/js-with-ts/jest-isolated.config.ts rename to examples/js-with-ts/jest-transpiler.config.ts index 06731f36cc..b4c60c93df 100644 --- a/examples/js-with-ts/jest-isolated.config.ts +++ b/examples/js-with-ts/jest-transpiler.config.ts @@ -4,7 +4,7 @@ import { createJsWithTsPreset } from 'ts-jest' export default { displayName: 'js-with-ts', ...createJsWithTsPreset({ - tsconfig: 'tsconfig-isolated.json', + transpilation: true, }), transformIgnorePatterns: ['!node_modules/(?!lodash-es)'], } satisfies Config diff --git a/examples/js-with-ts/package.json b/examples/js-with-ts/package.json index 0aa31bd353..adc94eb9fd 100644 --- a/examples/js-with-ts/package.json +++ b/examples/js-with-ts/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "test": "jest -c=jest.config.ts --no-cache", - "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-transpiler": "jest -c=jest-transpiler.config.ts --no-cache", "test-esm": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm.config.ts --no-cache", - "test-esm-isolated": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-isolated.config.ts --no-cache" + "test-esm-transpiler": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-transpiler.config.ts --no-cache" }, "devDependencies": { "@types/lodash-es": "^4.17.12", diff --git a/examples/js-with-ts/tsconfig-esm-isolated.json b/examples/js-with-ts/tsconfig-esm-isolated.json deleted file mode 100644 index d3468381f7..0000000000 --- a/examples/js-with-ts/tsconfig-esm-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/js-with-ts/tsconfig-isolated.json b/examples/js-with-ts/tsconfig-isolated.json deleted file mode 100644 index 4b8f61b29f..0000000000 --- a/examples/js-with-ts/tsconfig-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/monorepo-app/jest-esm-isolated.config.ts b/examples/monorepo-app/jest-esm-isolated.config.ts deleted file mode 100644 index 1fa544c2fa..0000000000 --- a/examples/monorepo-app/jest-esm-isolated.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Config } from 'jest' - -export default { - projects: [ - '/type-commonjs/jest-esm-isolated.config.ts', - '/type-module/jest-esm-isolated.config.ts', - ], -} satisfies Config diff --git a/examples/monorepo-app/jest-esm-transpiler.config.ts b/examples/monorepo-app/jest-esm-transpiler.config.ts new file mode 100644 index 0000000000..e7c90b8939 --- /dev/null +++ b/examples/monorepo-app/jest-esm-transpiler.config.ts @@ -0,0 +1,8 @@ +import type { Config } from 'jest' + +export default { + projects: [ + '/type-commonjs/jest-esm-transpiler.config.ts', + '/type-module/jest-esm-transpiler.config.ts', + ], +} satisfies Config diff --git a/examples/monorepo-app/jest-isolated.config.ts b/examples/monorepo-app/jest-isolated.config.ts deleted file mode 100644 index c5a3118097..0000000000 --- a/examples/monorepo-app/jest-isolated.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Config } from 'jest' - -export default { - projects: ['/type-commonjs/jest-isolated.config.ts', '/type-module/jest-isolated.config.ts'], -} satisfies Config diff --git a/examples/monorepo-app/jest-transpiler.config.ts b/examples/monorepo-app/jest-transpiler.config.ts new file mode 100644 index 0000000000..d175318d9c --- /dev/null +++ b/examples/monorepo-app/jest-transpiler.config.ts @@ -0,0 +1,5 @@ +import type { Config } from 'jest' + +export default { + projects: ['/type-commonjs/jest-transpiler.config.ts', '/type-module/jest-transpiler.config.ts'], +} satisfies Config diff --git a/examples/monorepo-app/package.json b/examples/monorepo-app/package.json index 2ee4d4db6f..2e2b8186b7 100644 --- a/examples/monorepo-app/package.json +++ b/examples/monorepo-app/package.json @@ -9,9 +9,9 @@ "scripts": { "build": "tsc -b", "test": "jest -c=jest.config.ts --no-cache", - "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-transpiler": "jest -c=jest-transpiler.config.ts --no-cache", "test-esm": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm.config.ts --no-cache", - "test-esm-isolated": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-isolated.config.ts --no-cache" + "test-esm-transpiler": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-transpiler.config.ts --no-cache" }, "devDependencies": { "@types/jest": "^30.0.0", diff --git a/examples/monorepo-app/type-commonjs/jest-esm-isolated.config.ts b/examples/monorepo-app/type-commonjs/jest-esm-transpiler.config.ts similarity index 72% rename from examples/monorepo-app/type-commonjs/jest-esm-isolated.config.ts rename to examples/monorepo-app/type-commonjs/jest-esm-transpiler.config.ts index 85eff2990c..7f20255863 100644 --- a/examples/monorepo-app/type-commonjs/jest-esm-isolated.config.ts +++ b/examples/monorepo-app/type-commonjs/jest-esm-transpiler.config.ts @@ -4,6 +4,7 @@ import { createDefaultEsmPreset } from 'ts-jest' export default { displayName: 'type-commonjs', ...createDefaultEsmPreset({ - tsconfig: '/tsconfig-esm-isolated.json', + tsconfig: '/tsconfig-esm.json', + transpilation: true, }), } satisfies Config diff --git a/examples/monorepo-app/type-commonjs/jest-isolated.config.ts b/examples/monorepo-app/type-commonjs/jest-transpiler.config.ts similarity index 78% rename from examples/monorepo-app/type-commonjs/jest-isolated.config.ts rename to examples/monorepo-app/type-commonjs/jest-transpiler.config.ts index edf6a487a1..a2a7f1bb50 100644 --- a/examples/monorepo-app/type-commonjs/jest-isolated.config.ts +++ b/examples/monorepo-app/type-commonjs/jest-transpiler.config.ts @@ -4,6 +4,6 @@ import { createDefaultPreset } from 'ts-jest' export default { displayName: 'type-commonjs', ...createDefaultPreset({ - tsconfig: '/tsconfig-isolated.json', + transpilation: true, }), } satisfies Config diff --git a/examples/monorepo-app/type-commonjs/tsconfig-esm-isolated.json b/examples/monorepo-app/type-commonjs/tsconfig-esm-isolated.json deleted file mode 100644 index d3468381f7..0000000000 --- a/examples/monorepo-app/type-commonjs/tsconfig-esm-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/monorepo-app/type-commonjs/tsconfig-isolated.json b/examples/monorepo-app/type-commonjs/tsconfig-isolated.json deleted file mode 100644 index 4b8f61b29f..0000000000 --- a/examples/monorepo-app/type-commonjs/tsconfig-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/monorepo-app/type-module/jest-esm-isolated.config.ts b/examples/monorepo-app/type-module/jest-esm-transpiler.config.ts similarity index 72% rename from examples/monorepo-app/type-module/jest-esm-isolated.config.ts rename to examples/monorepo-app/type-module/jest-esm-transpiler.config.ts index 2af9cf6455..8804ebf841 100644 --- a/examples/monorepo-app/type-module/jest-esm-isolated.config.ts +++ b/examples/monorepo-app/type-module/jest-esm-transpiler.config.ts @@ -4,6 +4,7 @@ import { createDefaultEsmPreset } from 'ts-jest' export default { displayName: 'type-module', ...createDefaultEsmPreset({ - tsconfig: '/tsconfig-esm-isolated.json', + tsconfig: '/tsconfig-esm.json', + transpilation: true, }), } satisfies Config diff --git a/examples/monorepo-app/type-module/jest-isolated.config.ts b/examples/monorepo-app/type-module/jest-transpiler.config.ts similarity index 78% rename from examples/monorepo-app/type-module/jest-isolated.config.ts rename to examples/monorepo-app/type-module/jest-transpiler.config.ts index b16793f1b3..ca8196f809 100644 --- a/examples/monorepo-app/type-module/jest-isolated.config.ts +++ b/examples/monorepo-app/type-module/jest-transpiler.config.ts @@ -4,6 +4,6 @@ import { createDefaultPreset } from 'ts-jest' export default { displayName: 'type-module', ...createDefaultPreset({ - tsconfig: '/tsconfig-isolated.json', + transpilation: true, }), } satisfies Config diff --git a/examples/monorepo-app/type-module/tsconfig-esm-isolated.json b/examples/monorepo-app/type-module/tsconfig-esm-isolated.json deleted file mode 100644 index d3468381f7..0000000000 --- a/examples/monorepo-app/type-module/tsconfig-esm-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/monorepo-app/type-module/tsconfig-isolated.json b/examples/monorepo-app/type-module/tsconfig-isolated.json deleted file mode 100644 index 4b8f61b29f..0000000000 --- a/examples/monorepo-app/type-module/tsconfig-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/package.json b/examples/package.json index a2d2ab74a6..1751804ce6 100644 --- a/examples/package.json +++ b/examples/package.json @@ -12,10 +12,10 @@ ], "scripts": { "test": "npm run test --workspaces", - "test-isolated": "npm run test-isolated --workspaces", + "test-transpiler": "npm run test-transpiler --workspaces", "test-esm": "npm run test-esm --workspaces", - "test-esm-isolated": "npm run test-esm-isolated --workspaces", - "test-all": "npm-run-all test test-isolated test-esm test-esm-isolated" + "test-esm-transpiler": "npm run test-esm-transpiler --workspaces", + "test-all": "npm-run-all test test-transpiler test-esm test-esm-transpiler" }, "devDependencies": { "npm-run-all": "^4.1.5" diff --git a/examples/react-app/jest-esm-isolated.config.ts b/examples/react-app/jest-esm-transpiler.config.ts similarity index 89% rename from examples/react-app/jest-esm-isolated.config.ts rename to examples/react-app/jest-esm-transpiler.config.ts index e612ee0a37..6b3a282b5a 100644 --- a/examples/react-app/jest-esm-isolated.config.ts +++ b/examples/react-app/jest-esm-transpiler.config.ts @@ -2,7 +2,8 @@ import type { Config } from 'jest' import { createDefaultEsmPreset } from 'ts-jest' const defaultPreset = createDefaultEsmPreset({ - tsconfig: 'tsconfig-esm-isolated.spec.json', + tsconfig: 'tsconfig-esm.spec.json', + transpilation: true, }) export default { diff --git a/examples/react-app/jest-isolated.config.ts b/examples/react-app/jest-transpiler.config.ts similarity index 89% rename from examples/react-app/jest-isolated.config.ts rename to examples/react-app/jest-transpiler.config.ts index 714ac2b73c..25600e430d 100644 --- a/examples/react-app/jest-isolated.config.ts +++ b/examples/react-app/jest-transpiler.config.ts @@ -2,7 +2,8 @@ import type { Config } from 'jest' import { createDefaultPreset } from 'ts-jest' const defaultPreset = createDefaultPreset({ - tsconfig: 'tsconfig-isolated.spec.json', + tsconfig: 'tsconfig.spec.json', + transpilation: true, }) export default { diff --git a/examples/react-app/package.json b/examples/react-app/package.json index b2f30d707c..fe2912a17c 100644 --- a/examples/react-app/package.json +++ b/examples/react-app/package.json @@ -6,9 +6,9 @@ "dev": "vite", "build": "tsc -b && vite build", "test": "jest -c=jest.config.ts --no-cache", - "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-transpiler": "jest -c=jest-transpiler.config.ts --no-cache", "test-esm": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm.config.ts --no-cache", - "test-esm-isolated": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-isolated.config.ts --no-cache", + "test-esm-transpiler": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-transpiler.config.ts --no-cache", "preview": "vite preview" }, "dependencies": { diff --git a/examples/react-app/tsconfig-esm-isolated.spec.json b/examples/react-app/tsconfig-esm-isolated.spec.json deleted file mode 100644 index 28c24ab660..0000000000 --- a/examples/react-app/tsconfig-esm-isolated.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/react-app/tsconfig-isolated.spec.json b/examples/react-app/tsconfig-isolated.spec.json deleted file mode 100644 index e9f49eb4e7..0000000000 --- a/examples/react-app/tsconfig-isolated.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.spec.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/ts-only/jest-esm-isolated.config.ts b/examples/ts-only/jest-esm-transpiler.config.ts similarity index 75% rename from examples/ts-only/jest-esm-isolated.config.ts rename to examples/ts-only/jest-esm-transpiler.config.ts index 8a323d6dc9..258c9a5e62 100644 --- a/examples/ts-only/jest-esm-isolated.config.ts +++ b/examples/ts-only/jest-esm-transpiler.config.ts @@ -4,6 +4,7 @@ import { createDefaultEsmPreset } from 'ts-jest' export default { displayName: 'ts-only', ...createDefaultEsmPreset({ - tsconfig: 'tsconfig-esm-isolated.json', + tsconfig: 'tsconfig-esm.json', + transpilation: true, }), } satisfies Config diff --git a/examples/ts-only/jest-isolated.config.ts b/examples/ts-only/jest-transpiler.config.ts similarity index 81% rename from examples/ts-only/jest-isolated.config.ts rename to examples/ts-only/jest-transpiler.config.ts index 2e4a6dfae1..122fb0d486 100644 --- a/examples/ts-only/jest-isolated.config.ts +++ b/examples/ts-only/jest-transpiler.config.ts @@ -4,6 +4,6 @@ import { createDefaultPreset } from 'ts-jest' export default { displayName: 'ts-only', ...createDefaultPreset({ - tsconfig: 'tsconfig-isolated.json', + transpilation: true, }), } satisfies Config diff --git a/examples/ts-only/package.json b/examples/ts-only/package.json index eb926912a2..122b4a9b62 100644 --- a/examples/ts-only/package.json +++ b/examples/ts-only/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "test": "jest -c=jest.config.ts --no-cache", - "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-transpiler": "jest -c=jest-transpiler.config.ts --no-cache", "test-esm": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm.config.ts --no-cache", - "test-esm-isolated": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-isolated.config.ts --no-cache" + "test-esm-transpiler": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest -c=jest-esm-transpiler.config.ts --no-cache" }, "devDependencies": { "@types/jest": "^30.0.0", diff --git a/examples/ts-only/tsconfig-esm-isolated.json b/examples/ts-only/tsconfig-esm-isolated.json deleted file mode 100644 index d3468381f7..0000000000 --- a/examples/ts-only/tsconfig-esm-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig-esm.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/examples/ts-only/tsconfig-isolated.json b/examples/ts-only/tsconfig-isolated.json deleted file mode 100644 index 4b8f61b29f..0000000000 --- a/examples/ts-only/tsconfig-isolated.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "isolatedModules": true - } -} diff --git a/jest.config.ts b/jest.config.ts index 61b191d870..fe56b96b3b 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -14,10 +14,10 @@ export default { { tsconfig: { target: 'ES2015', - isolatedModules: true, module: 'NodeNext', moduleResolution: 'NodeNext', }, + transpilation: true, }, ], }, diff --git a/src/legacy/compiler/ts-compiler.spec.ts b/src/legacy/compiler/ts-compiler.spec.ts index 9c2856f6a6..230c078983 100644 --- a/src/legacy/compiler/ts-compiler.spec.ts +++ b/src/legacy/compiler/ts-compiler.spec.ts @@ -138,8 +138,8 @@ describe('TsCompiler', () => { ...baseTsJestConfig, useESM, babelConfig, + transpilation: true, tsconfig: { - isolatedModules: true, customConditions: ['my-condition'], module, } as TsConfigJson, @@ -174,20 +174,31 @@ describe('TsCompiler', () => { }).toMatchSnapshot() }) - test.each([true, false])('should report diagnostics if shouldReportDiagnostics is %p', (shouldReport) => { + test.each([ + { + shouldReport: true, + expectedCall: 1, + }, + { + shouldReport: false, + expectedCall: 0, + }, + ])('should report diagnostics if shouldReportDiagnostics is %p', ({ shouldReport, expectedCall }) => { const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, useESM: false, + transpilation: true, + diagnostics: shouldReport, tsconfig: { - isolatedModules: true, module: 'CommonJS', }, }, }) compiler.configSet.raiseDiagnostics = jest.fn() compiler.configSet.shouldReportDiagnostics = jest.fn().mockReturnValue(shouldReport) - const compileOutput: TranspileOutput = { + // @ts-expect-error testing purpose + compiler._ts.transpileModule = jest.fn().mockReturnValueOnce({ sourceMapText: '{}', outputText: 'var bar = 1', diagnostics: [ @@ -200,33 +211,22 @@ describe('TsCompiler', () => { length: 1, }, ], - } - // @ts-expect-error testing purpose - compiler._ts.transpileModule = jest.fn().mockReturnValueOnce(compileOutput) + }) compiler.getCompiledOutput(fileContent, fileName, { depGraphs: new Map(), supportsStaticESM: true, watchMode: false, }) - if (shouldReport) { - expect(compiler.configSet.raiseDiagnostics).toHaveBeenCalledWith( - compileOutput.diagnostics, - fileName, - // @ts-expect-error testing purpose - compiler._logger, - ) - } else { - expect(compiler.configSet.raiseDiagnostics).not.toHaveBeenCalled() - } + expect(compiler.configSet.raiseDiagnostics).toHaveBeenCalledTimes(expectedCall) }) it('should use tsTranspileModule when Node16/NodeNext is used', () => { const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, + transpilation: true, tsconfig: { - isolatedModules: true, module: 'Node16', moduleResolution: 'Node16', }, diff --git a/src/legacy/compiler/ts-compiler.ts b/src/legacy/compiler/ts-compiler.ts index f7da0eb1a3..e674ede2ca 100644 --- a/src/legacy/compiler/ts-compiler.ts +++ b/src/legacy/compiler/ts-compiler.ts @@ -193,7 +193,7 @@ export class TsCompiler implements TsCompilerInstance { getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput { const isEsmMode = this.configSet.useESM && options.supportsStaticESM this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode) - if (!this._initialCompilerOptions.isolatedModules && isModernNodeModuleKind(this._initialCompilerOptions.module)) { + if (isModernNodeModuleKind(this._initialCompilerOptions.module) && !this.configSet.isolatedModules) { this._logger.warn(Helps.UsingModernNodeResolution) } diff --git a/src/legacy/config/config-set.spec.ts b/src/legacy/config/config-set.spec.ts index 7715ff5af3..14a857a693 100644 --- a/src/legacy/config/config-set.spec.ts +++ b/src/legacy/config/config-set.spec.ts @@ -11,7 +11,7 @@ import type { AstTransformerDesc, TsJestTransformerOptions } from '../../types' import { stringify } from '../../utils' import * as _backports from '../../utils/backports' import { getPackageVersion } from '../../utils/get-package-version' -import { Deprecations, Errors, interpolate } from '../../utils/messages' +import { Deprecations, Errors } from '../../utils/messages' import { normalizeSlashes } from '../../utils/normalize-slashes' import { sha1 } from '../../utils/sha1' @@ -1150,33 +1150,7 @@ describe('config-set', () => { describe('isolatedModules', () => { const spyFindTsConfigFile = jest.spyOn(ts, 'findConfigFile') - it('should show warning log when isolatedModules: true is used in transformer options when a tsconfig file path for tests exists', () => { - spyFindTsConfigFile.mockReturnValueOnce('foo/tsconfig.json') - const logger = testing.createLoggerMock() - createConfigSet({ - logger, - jestConfig: { - rootDir: 'src', - cwd: 'src', - } as any, // eslint-disable-line @typescript-eslint/no-explicit-any - tsJestConfig: { - isolatedModules: true, - }, - resolve: null, - }) - - expect(logger.target.filteredLines(LogLevels.warn)).toEqual( - expect.arrayContaining([ - expect.stringContaining( - interpolate(Deprecations.IsolatedModulesWithTsconfigPath, { - tsconfigFilePath: 'foo/tsconfig.json', - }), - ), - ]), - ) - }) - - it('should show warning log when isolatedModules: true is used in transformer options when a tsconfig file path does not exist', () => { + it('should show warning log when isolatedModules: true is used in transformer options', () => { spyFindTsConfigFile.mockReturnValueOnce(undefined) const logger = testing.createLoggerMock() createConfigSet({ @@ -1192,7 +1166,7 @@ describe('config-set', () => { }) expect(logger.target.filteredLines(LogLevels.warn)).toEqual( - expect.arrayContaining([expect.stringContaining(Deprecations.IsolatedModulesWithoutTsconfigPath)]), + expect.arrayContaining([expect.stringContaining(Deprecations.ReplaceIsolatedModulesWithTranspilation)]), ) }) }) diff --git a/src/legacy/config/config-set.ts b/src/legacy/config/config-set.ts index 37b1f81d29..a486c2a8ff 100644 --- a/src/legacy/config/config-set.ts +++ b/src/legacy/config/config-set.ts @@ -214,18 +214,9 @@ export class ConfigSet { this._matchTestFilePath = globsToMatcher(this._matchablePatterns.filter((pattern) => typeof pattern === 'string')) // isolatedModules if (options.isolatedModules) { - this.parsedTsConfig.options.isolatedModules = true - if (this.tsconfigFilePath) { - this.logger.warn( - interpolate(Deprecations.IsolatedModulesWithTsconfigPath, { - tsconfigFilePath: this.tsconfigFilePath, - }), - ) - } else { - this.logger.warn(Deprecations.IsolatedModulesWithoutTsconfigPath) - } + this.logger.warn(Deprecations.ReplaceIsolatedModulesWithTranspilation) } - this.isolatedModules = this.parsedTsConfig.options.isolatedModules ?? false + this.isolatedModules = options.isolatedModules ?? options.transpilation ?? false this._resolveTsCacheDir() } diff --git a/src/types.ts b/src/types.ts index a30bbf4c37..0d63e90058 100644 --- a/src/types.ts +++ b/src/types.ts @@ -77,14 +77,17 @@ export type TsJestGlobalOptions = Config.TransformerConfig[1] & { tsconfig?: boolean | string | RawCompilerOptions | TsConfigCompilerOptionsJson /** - * @deprecated use {@link TsConfigCompilerOptionsJson.isolatedModules} instead - * - * Compiles files as isolated modules (disables some features) - * - * @default `undefined` (disables transpiling files with {@link _ts.transpileModule}) + * @deprecated use {@link transpilation} instead */ isolatedModules?: boolean + /** + * Compiles files using {@link _ts.transpileModule}) + * + * @default `undefined` (disables) + */ + transpilation?: boolean + /** * Compiler to use * diff --git a/src/utils/messages.ts b/src/utils/messages.ts index abc22d4185..6729a1dcd4 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -28,7 +28,7 @@ export const enum Errors { export const enum Helps { FixMissingModule = '{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)', MigrateConfigUsingCLI = 'Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate .', - UsingModernNodeResolution = 'Using hybrid module kind (Node16/18/Next) is only supported in "isolatedModules: true". Please set "isolatedModules: true" in your tsconfig.json.', + UsingModernNodeResolution = 'Using hybrid module kind (Node16/18/Next) is only supported in "transpilation: true". Please set "transpilation: true" in for `ts-jest` config in your Jest config file.', } /** @@ -45,11 +45,8 @@ export const enum Deprecations { " : ['ts-jest', { /* ts-jest config goes here in Jest */ }],\n" + '},\n' + 'See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced', - IsolatedModulesWithTsconfigPath = ` - The "ts-jest" config option "isolatedModules" is deprecated and will be removed in v30.0.0. Please use "isolatedModules: true" in {{tsconfigFilePath}} instead, see https://www.typescriptlang.org/tsconfig/#isolatedModules - `, - IsolatedModulesWithoutTsconfigPath = ` - The "ts-jest" config option "isolatedModules" is deprecated and will be removed in v30.0.0. Please use "isolatedModules: true", see https://www.typescriptlang.org/tsconfig/#isolatedModules + ReplaceIsolatedModulesWithTranspilation = ` + The "ts-jest" config option "isolatedModules" is deprecated and will be removed in v30.0.0. Please use "transpilation: true" instead, see https://kulshekhar.github.io/ts-jest/docs/options/transpilation `, } diff --git a/website/docs/getting-started/options.md b/website/docs/getting-started/options.md index 7b572b283b..804811e2e7 100644 --- a/website/docs/getting-started/options.md +++ b/website/docs/getting-started/options.md @@ -41,7 +41,7 @@ All options have default values which should fit most of the projects. Click on | ------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ----------------------------- | -------------- | | [**`compiler`**][compiler] | [TypeScript module to use as compiler.][compiler] | `string` | `"typescript"` | | [**`tsconfig`**][tsconfig] | [TypeScript compiler related configuration.][tsconfig] | `string`\|`object`\|`boolean` | _auto_ | -| [**`isolatedModules`**][isolatedmodules] | [Disable type-checking][isolatedmodules] | `boolean` | _disabled_ | +| [**`transpilation`**][transpilation] | [Transpile code and disable type-checking][transpilation] | `boolean` | _disabled_ | | [**`astTransformers`**][asttransformers] | [Custom TypeScript AST transformers][asttransformers] | `object` | _auto_ | | [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ | | [**`babelConfig`**][babelconfig] | [Babel(Jest) related configuration.][babelconfig] | `boolean`\|`string`\|`object` | _disabled_ | @@ -50,7 +50,7 @@ All options have default values which should fit most of the projects. Click on [compiler]: options/compiler [tsconfig]: options/tsconfig -[isolatedmodules]: options/isolatedModules +[transpilation]: options/transpilation [asttransformers]: options/astTransformers [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig diff --git a/website/docs/getting-started/options/isolatedModules.md b/website/docs/getting-started/options/transpilation.md similarity index 55% rename from website/docs/getting-started/options/isolatedModules.md rename to website/docs/getting-started/options/transpilation.md index a8c65279ee..b5db2b988c 100644 --- a/website/docs/getting-started/options/isolatedModules.md +++ b/website/docs/getting-started/options/transpilation.md @@ -1,20 +1,14 @@ --- -title: isolatedModules option +title: transpilation option --- -:::warning DEPRECATED +By default `ts-jest` uses TypeScript Compiler API aka full `Program` in the context of a project (yours), with full type-checking and features. +But it can also be used to compile each file separately, which is usually named as `transpilation` like other tools `Babel`, `swc`, `esbuild` etc. +That's what the `transpilation` option (which defaults to `false`) does. -This page is now **DEPRECATED** and will be removed together with the config option `isolatedModules` in the next major release. Please use `isolatedModules` option in `tsconfig.json` instead. +You'll lose type-checking ability and all [TypeScript limitations](https://www.typescriptlang.org/tsconfig/#isolatedModules) are applied in trading off for faster test running. -::: - -By default `ts-jest` uses TypeScript compiler in the context of a project (yours), with full type-checking and features. -But it can also be used to compile each file separately, what TypeScript calls an 'isolated module'. -That's what the `isolatedModules` option (which defaults to `false`) does. - -You'll lose type-checking ability and some features such as `const enum`, but in the case you plan on using Jest with the cache disabled (`jest --no-cache`), your tests will then run much faster. - -Here is how to disable type-checking and compile each file as an isolated module: +Here is the example how to use the option ### Example @@ -29,7 +23,7 @@ const jestConfig: Config = { '^.+\\.tsx?$': [ 'ts-jest', { - isolatedModules: true, + transpilation: true, }, ], }, @@ -40,7 +34,7 @@ export default jestConfig ## Performance -Using `isolatedModules: false` comes with a cost of performance comparing to `isolatedModules: true`. There is a way +Using `transpilation: false` comes with a cost of performance comparing to `transpilation: true`. There is a way to improve the performance when using this mode by changing the value of `include` in `tsconfig` which is used by `ts-jest`. The least amount of files which are provided in `include`, the more performance the test run can gain. diff --git a/website/docs/getting-started/presets.md b/website/docs/getting-started/presets.md index dd993bcadf..f245fa3068 100644 --- a/website/docs/getting-started/presets.md +++ b/website/docs/getting-started/presets.md @@ -30,7 +30,7 @@ Create a configuration to process TypeScript files (`.ts`/`.tsx`). - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -45,7 +45,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -89,7 +89,7 @@ Create a **LEGACY** configuration to process TypeScript files (`.ts`, `.tsx`). - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -104,7 +104,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -129,7 +129,7 @@ export type DefaultPreset = { ```ts title="jest.config.ts" import { createDefaultLegacyPreset, type JestConfigWithTsJest } from 'ts-jest' -const presetConfig = createDefaultLegacyPreset({ +const presetConfig = createDefaultPreset({ //...optionsa }) @@ -148,7 +148,7 @@ Create an ESM configuration to process TypeScript files (`.ts`/`.mts`/`.tsx`/`.m - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -161,7 +161,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -206,7 +206,7 @@ Create a **LEGACY** ESM configuration to process TypeScript files (`.ts`/`.mts`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -221,7 +221,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -266,7 +266,7 @@ Create a configuration to process JavaScript/TypeScript files (`.js`/`.jsx`/`.ts - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -281,7 +281,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -325,7 +325,7 @@ Create a **LEGACY** configuration to process JavaScript/TypeScript files (`.js`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -338,7 +338,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -382,7 +382,7 @@ Create a ESM configuration to process JavaScript/TypeScript files (`.js`/`.mjs`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -397,7 +397,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -441,7 +441,7 @@ Create a **LEGACY** ESM configuration to process JavaScript/TypeScript files (`. - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -454,7 +454,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -498,7 +498,7 @@ Create a configuration to process JavaScript/TypeScript files (`.js`/`.jsx`/`.ts - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -514,7 +514,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -559,7 +559,7 @@ Create a **LEGACY** configuration to process JavaScript/TypeScript files (`.js`/ - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -573,7 +573,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -618,7 +618,7 @@ Create a ESM configuration to process JavaScript/TypeScript files (`.js`/`.mjs`/ - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -634,7 +634,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -679,7 +679,7 @@ Create a **LEGACY** ESM configuration to process JavaScript/TypeScript files (`. - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -693,7 +693,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean diff --git a/website/versioned_docs/version-29.4/getting-started/options.md b/website/versioned_docs/version-29.4/getting-started/options.md index 7b572b283b..804811e2e7 100644 --- a/website/versioned_docs/version-29.4/getting-started/options.md +++ b/website/versioned_docs/version-29.4/getting-started/options.md @@ -41,7 +41,7 @@ All options have default values which should fit most of the projects. Click on | ------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ----------------------------- | -------------- | | [**`compiler`**][compiler] | [TypeScript module to use as compiler.][compiler] | `string` | `"typescript"` | | [**`tsconfig`**][tsconfig] | [TypeScript compiler related configuration.][tsconfig] | `string`\|`object`\|`boolean` | _auto_ | -| [**`isolatedModules`**][isolatedmodules] | [Disable type-checking][isolatedmodules] | `boolean` | _disabled_ | +| [**`transpilation`**][transpilation] | [Transpile code and disable type-checking][transpilation] | `boolean` | _disabled_ | | [**`astTransformers`**][asttransformers] | [Custom TypeScript AST transformers][asttransformers] | `object` | _auto_ | | [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ | | [**`babelConfig`**][babelconfig] | [Babel(Jest) related configuration.][babelconfig] | `boolean`\|`string`\|`object` | _disabled_ | @@ -50,7 +50,7 @@ All options have default values which should fit most of the projects. Click on [compiler]: options/compiler [tsconfig]: options/tsconfig -[isolatedmodules]: options/isolatedModules +[transpilation]: options/transpilation [asttransformers]: options/astTransformers [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig diff --git a/website/versioned_docs/version-29.4/getting-started/options/isolatedModules.md b/website/versioned_docs/version-29.4/getting-started/options/transpilation.md similarity index 55% rename from website/versioned_docs/version-29.4/getting-started/options/isolatedModules.md rename to website/versioned_docs/version-29.4/getting-started/options/transpilation.md index a8c65279ee..b5db2b988c 100644 --- a/website/versioned_docs/version-29.4/getting-started/options/isolatedModules.md +++ b/website/versioned_docs/version-29.4/getting-started/options/transpilation.md @@ -1,20 +1,14 @@ --- -title: isolatedModules option +title: transpilation option --- -:::warning DEPRECATED +By default `ts-jest` uses TypeScript Compiler API aka full `Program` in the context of a project (yours), with full type-checking and features. +But it can also be used to compile each file separately, which is usually named as `transpilation` like other tools `Babel`, `swc`, `esbuild` etc. +That's what the `transpilation` option (which defaults to `false`) does. -This page is now **DEPRECATED** and will be removed together with the config option `isolatedModules` in the next major release. Please use `isolatedModules` option in `tsconfig.json` instead. +You'll lose type-checking ability and all [TypeScript limitations](https://www.typescriptlang.org/tsconfig/#isolatedModules) are applied in trading off for faster test running. -::: - -By default `ts-jest` uses TypeScript compiler in the context of a project (yours), with full type-checking and features. -But it can also be used to compile each file separately, what TypeScript calls an 'isolated module'. -That's what the `isolatedModules` option (which defaults to `false`) does. - -You'll lose type-checking ability and some features such as `const enum`, but in the case you plan on using Jest with the cache disabled (`jest --no-cache`), your tests will then run much faster. - -Here is how to disable type-checking and compile each file as an isolated module: +Here is the example how to use the option ### Example @@ -29,7 +23,7 @@ const jestConfig: Config = { '^.+\\.tsx?$': [ 'ts-jest', { - isolatedModules: true, + transpilation: true, }, ], }, @@ -40,7 +34,7 @@ export default jestConfig ## Performance -Using `isolatedModules: false` comes with a cost of performance comparing to `isolatedModules: true`. There is a way +Using `transpilation: false` comes with a cost of performance comparing to `transpilation: true`. There is a way to improve the performance when using this mode by changing the value of `include` in `tsconfig` which is used by `ts-jest`. The least amount of files which are provided in `include`, the more performance the test run can gain. diff --git a/website/versioned_docs/version-29.4/getting-started/presets.md b/website/versioned_docs/version-29.4/getting-started/presets.md index fec1b0a177..f245fa3068 100644 --- a/website/versioned_docs/version-29.4/getting-started/presets.md +++ b/website/versioned_docs/version-29.4/getting-started/presets.md @@ -30,7 +30,7 @@ Create a configuration to process TypeScript files (`.ts`/`.tsx`). - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -45,7 +45,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -89,7 +89,7 @@ Create a **LEGACY** configuration to process TypeScript files (`.ts`, `.tsx`). - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -104,7 +104,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -148,7 +148,7 @@ Create an ESM configuration to process TypeScript files (`.ts`/`.mts`/`.tsx`/`.m - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -161,7 +161,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -206,7 +206,7 @@ Create a **LEGACY** ESM configuration to process TypeScript files (`.ts`/`.mts`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -221,7 +221,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -266,7 +266,7 @@ Create a configuration to process JavaScript/TypeScript files (`.js`/`.jsx`/`.ts - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -281,7 +281,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -325,7 +325,7 @@ Create a **LEGACY** configuration to process JavaScript/TypeScript files (`.js`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -338,7 +338,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -382,7 +382,7 @@ Create a ESM configuration to process JavaScript/TypeScript files (`.js`/`.mjs`/ - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -397,7 +397,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -441,7 +441,7 @@ Create a **LEGACY** ESM configuration to process JavaScript/TypeScript files (`. - `options` (**OPTIONAL**) - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -454,7 +454,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -498,7 +498,7 @@ Create a configuration to process JavaScript/TypeScript files (`.js`/`.jsx`/`.ts - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -514,7 +514,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -559,7 +559,7 @@ Create a **LEGACY** configuration to process JavaScript/TypeScript files (`.js`/ - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -573,7 +573,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -618,7 +618,7 @@ Create a ESM configuration to process JavaScript/TypeScript files (`.js`/`.mjs`/ - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -634,7 +634,7 @@ import type { TsConfigJson } from 'type-fest' interface TsJestTransformerOptions { tsconfig?: boolean | string | TsConfigJson.CompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean @@ -679,7 +679,7 @@ Create a **LEGACY** ESM configuration to process JavaScript/TypeScript files (`. - `options` (**OPTIONAL**): - `tsconfig`: see more at [tsconfig options page](./options/tsconfig.md) - - `isolatedModules`: see more at [isolatedModules options page](./options/isolatedModules.md) + - `transpilation`: see more at [transpilation options page](./options/transpilation.md) - `compiler`: see more at [compiler options page](./options/compiler.md) - `astTransformers`: see more at [astTransformers options page](./options/astTransformers.md) - `diagnostics`: see more at [diagnostics options page](./options/diagnostics.md) @@ -693,7 +693,7 @@ An object contains Jest's `transform` property: ```ts interface TsJestTransformerOptions { tsconfig?: boolean | string | RawCompilerOptions - isolatedModules?: boolean + transpilation?: boolean astTransformers?: ConfigCustomTransformer diagnostics?: | boolean