From b0464e9cd57c52bbc65835b6ec784629cf5e7f73 Mon Sep 17 00:00:00 2001 From: Ahn Date: Sun, 30 Aug 2020 18:16:10 +0200 Subject: [PATCH] refactor(presets): simplify create presets codes (#1911) --- .../module-kinds/ts-jest-tools.spec.ts | 21 ---------------- e2e/__cases__/presets/ts-jest-presets.spec.ts | 12 +++++++++ e2e/__cases__/utils/ts-jest-utils.spec.ts | 8 ++++++ .../__snapshots__/logger.test.ts.snap | 3 +++ .../__snapshots__/amd.test.ts.snap | 25 ++++++++----------- .../__snapshots__/commonjs.test.ts.snap | 25 ++++++++----------- .../__snapshots__/es2015.test.ts.snap | 25 ++++++++----------- .../__snapshots__/esnext.test.ts.snap | 25 ++++++++----------- .../__snapshots__/none.test.ts.snap | 25 ++++++++----------- .../__snapshots__/system.test.ts.snap | 25 ++++++++----------- .../__snapshots__/umd.test.ts.snap | 25 ++++++++----------- e2e/__tests__/ts-jest-presets.test.ts | 13 ++++++++++ e2e/__tests__/ts-jest-utils.test.ts | 13 ++++++++++ jest-preset.js | 2 +- presets/create.js | 1 - presets/index.d.ts | 5 ---- presets/index.js | 21 +--------------- src/cli/helpers/presets.ts | 2 +- src/index.spec.ts | 2 +- src/index.ts | 2 +- .../create-jest-preset.spec.ts | 0 src/{config => presets}/create-jest-preset.ts | 2 +- src/presets/index.ts | 20 +++++++++++++++ src/utils/index.spec.ts | 2 +- src/utils/index.ts | 2 +- 25 files changed, 147 insertions(+), 159 deletions(-) delete mode 100644 e2e/__cases__/module-kinds/ts-jest-tools.spec.ts create mode 100644 e2e/__cases__/presets/ts-jest-presets.spec.ts create mode 100644 e2e/__cases__/utils/ts-jest-utils.spec.ts create mode 100644 e2e/__tests__/ts-jest-presets.test.ts create mode 100644 e2e/__tests__/ts-jest-utils.test.ts delete mode 100644 presets/create.js delete mode 100644 presets/index.d.ts rename src/{config => presets}/create-jest-preset.spec.ts (100%) rename src/{config => presets}/create-jest-preset.ts (95%) create mode 100644 src/presets/index.ts diff --git a/e2e/__cases__/module-kinds/ts-jest-tools.spec.ts b/e2e/__cases__/module-kinds/ts-jest-tools.spec.ts deleted file mode 100644 index 7dcf795b77..0000000000 --- a/e2e/__cases__/module-kinds/ts-jest-tools.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -// preset and utils should work all the time -import * as presets from 'ts-jest/presets' -import * as utils from 'ts-jest/utils' - -test('presets', () => { - const presetKeys = ['transform'] - expect(Object.keys(presets.defaults)).toEqual(presetKeys) - expect(presets.defaults).toEqual(require('ts-jest/presets/default/jest-preset')) - expect(presets.defaults).toEqual(require('ts-jest/jest-preset')) - expect(Object.keys(presets.jsWithTs)).toEqual(presetKeys) - expect(presets.jsWithTs).toEqual(require('ts-jest/presets/js-with-ts/jest-preset')) - expect(Object.keys(presets.jsWithBabel)).toEqual(presetKeys) - expect(presets.jsWithBabel).toEqual(require('ts-jest/presets/js-with-babel/jest-preset')) -}) - -test('utils', () => { - expect(Object.keys(utils)).toEqual(['mocked', 'createJestPreset', 'pathsToModuleNameMapper']) - expect(typeof utils.mocked).toBe('function') - expect(typeof utils.createJestPreset).toBe('function') - expect(typeof utils.pathsToModuleNameMapper).toBe('function') -}) diff --git a/e2e/__cases__/presets/ts-jest-presets.spec.ts b/e2e/__cases__/presets/ts-jest-presets.spec.ts new file mode 100644 index 0000000000..fb08a2c7ba --- /dev/null +++ b/e2e/__cases__/presets/ts-jest-presets.spec.ts @@ -0,0 +1,12 @@ +// preset and utils should work all the time +import * as presets from 'ts-jest/presets' + +test('presets', () => { + const presetKeys = ['transform'] + expect(presets.defaults).toEqual(require('ts-jest/dist/presets').defaults) + expect(Object.keys(presets.defaults)).toEqual(presetKeys) + expect(presets.jsWithBabel).toEqual(require('ts-jest/dist/presets').jsWithBabel) + expect(Object.keys(presets.jsWithBabel)).toEqual(presetKeys) + expect(presets.jsWithTs).toEqual(require('ts-jest/dist/presets').jsWithTs) + expect(Object.keys(presets.jsWithTs)).toEqual(presetKeys) +}) diff --git a/e2e/__cases__/utils/ts-jest-utils.spec.ts b/e2e/__cases__/utils/ts-jest-utils.spec.ts new file mode 100644 index 0000000000..a70d33afb2 --- /dev/null +++ b/e2e/__cases__/utils/ts-jest-utils.spec.ts @@ -0,0 +1,8 @@ +import * as utils from 'ts-jest/utils' + +test('utils', () => { + expect(Object.keys(utils)).toEqual(['mocked', 'createJestPreset', 'pathsToModuleNameMapper']) + expect(typeof utils.mocked).toBe('function') + expect(typeof utils.createJestPreset).toBe('function') + expect(typeof utils.pathsToModuleNameMapper).toBe('function') +}) diff --git a/e2e/__tests__/__snapshots__/logger.test.ts.snap b/e2e/__tests__/__snapshots__/logger.test.ts.snap index 0f57c4ebd5..5a7166c439 100644 --- a/e2e/__tests__/__snapshots__/logger.test.ts.snap +++ b/e2e/__tests__/__snapshots__/logger.test.ts.snap @@ -2,6 +2,7 @@ exports[`ts-jest logging TS_JEST_LOG should pass and create log file when using template "default" 1`] = ` Array [ + "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating Importer singleton", "[level:20] creating jest presets not handling JavaScript files", @@ -39,6 +40,7 @@ Array [ exports[`ts-jest logging TS_JEST_LOG should pass and create log file when using template "with-babel-7" 1`] = ` Array [ + "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating Importer singleton", "[level:20] creating jest presets not handling JavaScript files", @@ -82,6 +84,7 @@ Array [ exports[`ts-jest logging TS_JEST_LOG should pass and create log file when using template "with-babel-7-string-config" 1`] = ` Array [ + "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating jest presets not handling JavaScript files", "[level:20] creating Importer singleton", "[level:20] creating jest presets not handling JavaScript files", diff --git a/e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap index 914c0083ba..9eead8f7fd 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false} ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false} at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true} ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true} at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"amd","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"amd","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"amd"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"amd"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap index 16ae3ec14b..2225609814 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap @@ -6,7 +6,6 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -36,8 +35,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -50,7 +49,6 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -71,8 +69,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -85,7 +83,6 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":false} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -115,8 +112,8 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -129,7 +126,6 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -161,8 +157,8 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -175,7 +171,6 @@ exports[`run with options: {"module":"commonjs"} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -205,8 +200,8 @@ exports[`run with options: {"module":"commonjs"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap index 9bc6007ae7..66273beda9 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"es2015","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"es2015","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"es2015"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"es2015"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap index 16326746b2..22b92e0653 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":tru ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":tru at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"esnext","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"esnext","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"esnext","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"esnext","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"esnext"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"esnext"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/none.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/none.test.ts.snap index ea278574f3..37dfd9fe5d 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/none.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/none.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"none","allowSyntheticDefaultImports":false ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"none","allowSyntheticDefaultImports":false at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"none","allowSyntheticDefaultImports":true} ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"none","allowSyntheticDefaultImports":true} at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"none","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"none","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"none","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"none","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"none"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"none"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/system.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/system.test.ts.snap index acb9d8e6c7..4deb7c7473 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/system.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/system.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"system","allowSyntheticDefaultImports":fal ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"system","allowSyntheticDefaultImports":fal at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"system","allowSyntheticDefaultImports":tru ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"system","allowSyntheticDefaultImports":tru at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"system","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"system","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"system","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"system","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"system"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"system"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/module-kinds/__snapshots__/umd.test.ts.snap b/e2e/__tests__/module-kinds/__snapshots__/umd.test.ts.snap index c443c37fb2..fa1686cbe4 100644 --- a/e2e/__tests__/module-kinds/__snapshots__/umd.test.ts.snap +++ b/e2e/__tests__/module-kinds/__snapshots__/umd.test.ts.snap @@ -7,7 +7,6 @@ exports[`run with options: {"module":"umd","allowSyntheticDefaultImports":false} ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts ts-jest[ts-compiler] (WARN) import-default.spec.ts:1:8 - error TS1259: Module '"/lib"' can only be default-imported using the 'esModuleInterop' flag @@ -37,8 +36,8 @@ exports[`run with options: {"module":"umd","allowSyntheticDefaultImports":false} at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -51,7 +50,6 @@ exports[`run with options: {"module":"umd","allowSyntheticDefaultImports":true} ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -72,8 +70,8 @@ exports[`run with options: {"module":"umd","allowSyntheticDefaultImports":true} at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -87,7 +85,6 @@ exports[`run with options: {"module":"umd","esModuleInterop":false} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -108,8 +105,8 @@ exports[`run with options: {"module":"umd","esModuleInterop":false} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -122,7 +119,6 @@ exports[`run with options: {"module":"umd","esModuleInterop":true} 1`] = ` ===[ STDOUT ]=================================================================== ===[ STDERR ]=================================================================== - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts ts-jest[ts-compiler] (WARN) import-star.spec.ts:5:10 - error TS2349: This expression is not callable. Type 'typeof lib' has no call signatures. @@ -154,8 +150,8 @@ exports[`run with options: {"module":"umd","esModuleInterop":true} 1`] = ` PASS ./import-default.spec.ts - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. @@ -169,7 +165,6 @@ exports[`run with options: {"module":"umd"} 1`] = ` ===[ STDERR ]=================================================================== ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting \`esModuleInterop\` to \`true\` in your TypeScript configuration file (usually \`tsconfig.json\`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. - PASS ./ts-jest-tools.spec.ts PASS ./import-legacy.spec.ts PASS ./import-star.spec.ts FAIL ./import-default.spec.ts @@ -190,8 +185,8 @@ exports[`run with options: {"module":"umd"} 1`] = ` at Object. (import-default.spec.ts:4:22) - Test Suites: 1 failed, 3 passed, 4 total - Tests: 1 failed, 4 passed, 5 total + Test Suites: 1 failed, 2 passed, 3 total + Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: XXs Ran all test suites. diff --git a/e2e/__tests__/ts-jest-presets.test.ts b/e2e/__tests__/ts-jest-presets.test.ts new file mode 100644 index 0000000000..eebf4bc9fa --- /dev/null +++ b/e2e/__tests__/ts-jest-presets.test.ts @@ -0,0 +1,13 @@ +import { allValidPackageSets } from '../__helpers__/templates' +import { configureTestCase } from '../__helpers__/test-case' + +describe('ts-jest presets', () => { + const testCase = configureTestCase('presets') + + testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => { + it(testLabel, () => { + const result = runTest() + expect(result.status).toBe(0) + }) + }) +}) diff --git a/e2e/__tests__/ts-jest-utils.test.ts b/e2e/__tests__/ts-jest-utils.test.ts new file mode 100644 index 0000000000..796dd579aa --- /dev/null +++ b/e2e/__tests__/ts-jest-utils.test.ts @@ -0,0 +1,13 @@ +import { allValidPackageSets } from '../__helpers__/templates' +import { configureTestCase } from '../__helpers__/test-case' + +describe('ts-jest utils', () => { + const testCase = configureTestCase('utils') + + testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => { + it(testLabel, () => { + const result = runTest() + expect(result.status).toBe(0) + }) + }) +}) diff --git a/jest-preset.js b/jest-preset.js index 54b108e345..41d20c9676 100644 --- a/jest-preset.js +++ b/jest-preset.js @@ -1 +1 @@ -module.exports = require('./presets/default/jest-preset') +module.exports = require('./presets').defaults diff --git a/presets/create.js b/presets/create.js deleted file mode 100644 index 50c361c351..0000000000 --- a/presets/create.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/config/create-jest-preset').createJestPreset diff --git a/presets/index.d.ts b/presets/index.d.ts deleted file mode 100644 index b1e0e57b65..0000000000 --- a/presets/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TsJestPresets } from '../dist/config/create-jest-preset' - -export const defaults: TsJestPresets -export const jsWithTs: TsJestPresets -export const jsWithBabel: TsJestPresets diff --git a/presets/index.js b/presets/index.js index 0417538e7c..d59f0c010e 100644 --- a/presets/index.js +++ b/presets/index.js @@ -1,20 +1 @@ -const create = require('./create') - -module.exports = { - get defaults() { - return create() - }, - get jsWithTs() { - return create({ allowJs: true }) - }, - get jsWithBabel() { - return create( - { allowJs: false }, - { - transform: { - '^.+\\.jsx?$': 'babel-jest', - }, - } - ) - }, -} +module.exports = require('../dist/presets') diff --git a/src/cli/helpers/presets.ts b/src/cli/helpers/presets.ts index b030e6b7b9..00490a5ff1 100644 --- a/src/cli/helpers/presets.ts +++ b/src/cli/helpers/presets.ts @@ -1,4 +1,4 @@ -import type { TsJestPresets } from '../../config/create-jest-preset' +import type { TsJestPresets } from '../../presets/create-jest-preset' /** @internal */ export const enum JestPresetNames { diff --git a/src/index.spec.ts b/src/index.spec.ts index d7aed572c6..72ec71904a 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -13,7 +13,7 @@ jest.mock('./ts-jest-transformer', () => { return { TsJestTransformer } }) -jest.mock('./config/create-jest-preset', () => ({ +jest.mock('./presets/create-jest-preset', () => ({ createJestPreset: () => ({ jestPreset: true }), })) diff --git a/src/index.ts b/src/index.ts index 9d7c6c642f..b66ace209c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import { LogContexts, LogLevels } from 'bs-logger' import { readFileSync } from 'fs' import { resolve } from 'path' -import { createJestPreset as createJestPresetCore } from './config/create-jest-preset' +import { createJestPreset as createJestPresetCore } from './presets/create-jest-preset' import { pathsToModuleNameMapper as pathsToModuleNameMapperCore } from './config/paths-to-module-name-mapper' import { TsJestTransformer } from './ts-jest-transformer' import type { TsJestGlobalOptions } from './types' diff --git a/src/config/create-jest-preset.spec.ts b/src/presets/create-jest-preset.spec.ts similarity index 100% rename from src/config/create-jest-preset.spec.ts rename to src/presets/create-jest-preset.spec.ts diff --git a/src/config/create-jest-preset.ts b/src/presets/create-jest-preset.ts similarity index 95% rename from src/config/create-jest-preset.ts rename to src/presets/create-jest-preset.ts index 50ea91f571..0b48c79eac 100644 --- a/src/config/create-jest-preset.ts +++ b/src/presets/create-jest-preset.ts @@ -6,7 +6,7 @@ const logger = rootLogger.child({ namespace: 'jest-preset' }) export type TsJestPresets = Pick -export interface CreateJestPresetOptions { +interface CreateJestPresetOptions { allowJs?: boolean } diff --git a/src/presets/index.ts b/src/presets/index.ts new file mode 100644 index 0000000000..bc109e5446 --- /dev/null +++ b/src/presets/index.ts @@ -0,0 +1,20 @@ +import { createJestPreset, TsJestPresets } from './create-jest-preset' + +export = { + get defaults(): TsJestPresets { + return createJestPreset() + }, + get jsWithTs(): TsJestPresets { + return createJestPreset({ allowJs: true }) + }, + get jsWithBabel(): TsJestPresets { + return createJestPreset( + { allowJs: false }, + { + transform: { + '^.+\\.jsx?$': 'babel-jest', + }, + }, + ) + }, +} diff --git a/src/utils/index.spec.ts b/src/utils/index.spec.ts index 6f06fcb4b4..f4ef8a378f 100644 --- a/src/utils/index.spec.ts +++ b/src/utils/index.spec.ts @@ -1,4 +1,4 @@ -import { createJestPreset } from '../config/create-jest-preset' +import { createJestPreset } from '../presets/create-jest-preset' import { pathsToModuleNameMapper } from '../config/paths-to-module-name-mapper' import * as subject from './index' diff --git a/src/utils/index.ts b/src/utils/index.ts index f051fd7e00..90d122d05d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,3 @@ export { mocked } from './testing' -export { createJestPreset } from '../config/create-jest-preset' +export { createJestPreset } from '../presets/create-jest-preset' export { pathsToModuleNameMapper } from '../config/paths-to-module-name-mapper'