Skip to content

Commit

Permalink
refactor(presets): simplify create presets codes (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Aug 30, 2020
1 parent b1dbcca commit b0464e9
Show file tree
Hide file tree
Showing 25 changed files with 147 additions and 159 deletions.
21 changes: 0 additions & 21 deletions e2e/__cases__/module-kinds/ts-jest-tools.spec.ts

This file was deleted.

12 changes: 12 additions & 0 deletions 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)
})
8 changes: 8 additions & 0 deletions 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')
})
3 changes: 3 additions & 0 deletions e2e/__tests__/__snapshots__/logger.test.ts.snap
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
25 changes: 10 additions & 15 deletions e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap
Expand Up @@ -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 '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
Expand Down Expand Up @@ -37,8 +36,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
at Object.<anonymous> (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.
Expand All @@ -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
Expand All @@ -72,8 +70,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true}
at Object.<anonymous> (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.
Expand All @@ -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
Expand All @@ -108,8 +105,8 @@ exports[`run with options: {"module":"amd","esModuleInterop":false} 1`] = `
at Object.<anonymous> (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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -190,8 +185,8 @@ exports[`run with options: {"module":"amd"} 1`] = `
at Object.<anonymous> (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.
Expand Down
25 changes: 10 additions & 15 deletions e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap
Expand Up @@ -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 '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
Expand Down Expand Up @@ -36,8 +35,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f
at Object.<anonymous> (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.
Expand All @@ -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
Expand All @@ -71,8 +69,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t
at Object.<anonymous> (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.
Expand All @@ -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 '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
Expand Down Expand Up @@ -115,8 +112,8 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":false} 1`] = `
at Object.<anonymous> (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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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 '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
Expand Down Expand Up @@ -205,8 +200,8 @@ exports[`run with options: {"module":"commonjs"} 1`] = `
at Object.<anonymous> (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.
Expand Down
25 changes: 10 additions & 15 deletions e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap
Expand Up @@ -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 '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
Expand Down Expand Up @@ -37,8 +36,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
at Object.<anonymous> (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.
Expand All @@ -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
Expand All @@ -72,8 +70,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru
at Object.<anonymous> (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.
Expand All @@ -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
Expand All @@ -108,8 +105,8 @@ exports[`run with options: {"module":"es2015","esModuleInterop":false} 1`] = `
at Object.<anonymous> (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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -190,8 +185,8 @@ exports[`run with options: {"module":"es2015"} 1`] = `
at Object.<anonymous> (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.
Expand Down

0 comments on commit b0464e9

Please sign in to comment.