Skip to content

Commit 94dc4e7

Browse files
committed
fix(typings): wrong import in preset typings + test
1 parent 53767ab commit 94dc4e7

File tree

9 files changed

+106
-57
lines changed

9 files changed

+106
-57
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// preset and utils should work all the time
2+
import * as presets from 'ts-jest/presets'
3+
import * as utils from 'ts-jest/utils'
4+
5+
test('presets', () => {
6+
const presetKeys = ['transform', 'testMatch', 'moduleFileExtensions']
7+
expect(Object.keys(presets.defaults)).toEqual(presetKeys)
8+
expect(presets.defaults).toEqual(require('ts-jest/presets/default/jest-preset'))
9+
expect(presets.defaults).toEqual(require('ts-jest/jest-preset'))
10+
expect(Object.keys(presets.jsWithTs)).toEqual(presetKeys)
11+
expect(presets.jsWithTs).toEqual(require('ts-jest/presets/js-with-ts/jest-preset'))
12+
expect(Object.keys(presets.jsWithBabel)).toEqual(presetKeys)
13+
expect(presets.jsWithBabel).toEqual(require('ts-jest/presets/js-with-babel/jest-preset'))
14+
})
15+
16+
test('utils', () => {
17+
expect(Object.keys(utils)).toEqual(['mocked', 'createJestPreset', 'pathsToModuleNameMapper'])
18+
expect(typeof utils.mocked).toBe('function')
19+
expect(typeof utils.createJestPreset).toBe('function')
20+
expect(typeof utils.pathsToModuleNameMapper).toBe('function')
21+
})

e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
88
===[ STDERR ]===================================================================
99
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
1010
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.
11+
PASS ./ts-jest-tools.spec.ts
1112
PASS ./import-legacy.spec.ts
1213
PASS ./import-star.spec.ts
1314
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
@@ -33,8 +34,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
3334
3435
at Object.<anonymous> (import-default.spec.ts:4:22)
3536
36-
Test Suites: 1 failed, 2 passed, 3 total
37-
Tests: 1 failed, 2 passed, 3 total
37+
Test Suites: 1 failed, 3 passed, 4 total
38+
Tests: 1 failed, 4 passed, 5 total
3839
Snapshots: 0 total
3940
Time: XXs
4041
Ran all test suites.
@@ -47,6 +48,7 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true}
4748
===[ STDOUT ]===================================================================
4849
4950
===[ STDERR ]===================================================================
51+
PASS ./ts-jest-tools.spec.ts
5052
PASS ./import-legacy.spec.ts
5153
PASS ./import-star.spec.ts
5254
FAIL ./import-default.spec.ts
@@ -67,8 +69,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true}
6769
6870
at Object.<anonymous> (import-default.spec.ts:4:22)
6971
70-
Test Suites: 1 failed, 2 passed, 3 total
71-
Tests: 1 failed, 2 passed, 3 total
72+
Test Suites: 1 failed, 3 passed, 4 total
73+
Tests: 1 failed, 4 passed, 5 total
7274
Snapshots: 0 total
7375
Time: XXs
7476
Ran all test suites.
@@ -81,6 +83,7 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = `
8183
===[ STDOUT ]===================================================================
8284
8385
===[ STDERR ]===================================================================
86+
PASS ./ts-jest-tools.spec.ts
8487
PASS ./import-legacy.spec.ts
8588
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
8689
import-star.spec.ts:5:10 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof lib' has no compatible call signatures.
@@ -112,8 +115,8 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = `
112115
113116
PASS ./import-default.spec.ts
114117
115-
Test Suites: 1 failed, 2 passed, 3 total
116-
Tests: 1 failed, 2 passed, 3 total
118+
Test Suites: 1 failed, 3 passed, 4 total
119+
Tests: 1 failed, 4 passed, 5 total
117120
Snapshots: 0 total
118121
Time: XXs
119122
Ran all test suites.
@@ -128,6 +131,7 @@ exports[`run with options: {"module":"amd"} 1`] = `
128131
===[ STDERR ]===================================================================
129132
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
130133
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.
134+
PASS ./ts-jest-tools.spec.ts
131135
PASS ./import-legacy.spec.ts
132136
PASS ./import-star.spec.ts
133137
FAIL ./import-default.spec.ts
@@ -148,8 +152,8 @@ exports[`run with options: {"module":"amd"} 1`] = `
148152
149153
at Object.<anonymous> (import-default.spec.ts:4:22)
150154
151-
Test Suites: 1 failed, 2 passed, 3 total
152-
Tests: 1 failed, 2 passed, 3 total
155+
Test Suites: 1 failed, 3 passed, 4 total
156+
Tests: 1 failed, 4 passed, 5 total
153157
Snapshots: 0 total
154158
Time: XXs
155159
Ran all test suites.

e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f
66
===[ STDOUT ]===================================================================
77
88
===[ STDERR ]===================================================================
9+
PASS ./ts-jest-tools.spec.ts
910
PASS ./import-legacy.spec.ts
1011
PASS ./import-star.spec.ts
1112
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
@@ -31,8 +32,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f
3132
3233
at Object.<anonymous> (import-default.spec.ts:4:22)
3334
34-
Test Suites: 1 failed, 2 passed, 3 total
35-
Tests: 1 failed, 2 passed, 3 total
35+
Test Suites: 1 failed, 3 passed, 4 total
36+
Tests: 1 failed, 4 passed, 5 total
3637
Snapshots: 0 total
3738
Time: XXs
3839
Ran all test suites.
@@ -45,6 +46,7 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t
4546
===[ STDOUT ]===================================================================
4647
4748
===[ STDERR ]===================================================================
49+
PASS ./ts-jest-tools.spec.ts
4850
PASS ./import-legacy.spec.ts
4951
PASS ./import-star.spec.ts
5052
FAIL ./import-default.spec.ts
@@ -65,8 +67,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t
6567
6668
at Object.<anonymous> (import-default.spec.ts:4:22)
6769
68-
Test Suites: 1 failed, 2 passed, 3 total
69-
Tests: 1 failed, 2 passed, 3 total
70+
Test Suites: 1 failed, 3 passed, 4 total
71+
Tests: 1 failed, 4 passed, 5 total
7072
Snapshots: 0 total
7173
Time: XXs
7274
Ran all test suites.
@@ -79,6 +81,7 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = `
7981
===[ STDOUT ]===================================================================
8082
8183
===[ STDERR ]===================================================================
84+
PASS ./ts-jest-tools.spec.ts
8285
PASS ./import-legacy.spec.ts
8386
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
8487
import-star.spec.ts:5:10 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof lib' has no compatible call signatures.
@@ -110,8 +113,8 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = `
110113
111114
PASS ./import-default.spec.ts
112115
113-
Test Suites: 1 failed, 2 passed, 3 total
114-
Tests: 1 failed, 2 passed, 3 total
116+
Test Suites: 1 failed, 3 passed, 4 total
117+
Tests: 1 failed, 4 passed, 5 total
115118
Snapshots: 0 total
116119
Time: XXs
117120
Ran all test suites.
@@ -124,6 +127,7 @@ exports[`run with options: {"module":"commonjs"} 1`] = `
124127
===[ STDOUT ]===================================================================
125128
126129
===[ STDERR ]===================================================================
130+
PASS ./ts-jest-tools.spec.ts
127131
PASS ./import-legacy.spec.ts
128132
PASS ./import-star.spec.ts
129133
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
@@ -149,8 +153,8 @@ exports[`run with options: {"module":"commonjs"} 1`] = `
149153
150154
at Object.<anonymous> (import-default.spec.ts:4:22)
151155
152-
Test Suites: 1 failed, 2 passed, 3 total
153-
Tests: 1 failed, 2 passed, 3 total
156+
Test Suites: 1 failed, 3 passed, 4 total
157+
Tests: 1 failed, 4 passed, 5 total
154158
Snapshots: 0 total
155159
Time: XXs
156160
Ran all test suites.

e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
88
===[ STDERR ]===================================================================
99
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
1010
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.
11+
PASS ./ts-jest-tools.spec.ts
1112
PASS ./import-legacy.spec.ts
1213
PASS ./import-star.spec.ts
1314
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
@@ -33,8 +34,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
3334
3435
at Object.<anonymous> (import-default.spec.ts:4:22)
3536
36-
Test Suites: 1 failed, 2 passed, 3 total
37-
Tests: 1 failed, 2 passed, 3 total
37+
Test Suites: 1 failed, 3 passed, 4 total
38+
Tests: 1 failed, 4 passed, 5 total
3839
Snapshots: 0 total
3940
Time: XXs
4041
Ran all test suites.
@@ -47,6 +48,7 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru
4748
===[ STDOUT ]===================================================================
4849
4950
===[ STDERR ]===================================================================
51+
PASS ./ts-jest-tools.spec.ts
5052
PASS ./import-legacy.spec.ts
5153
PASS ./import-star.spec.ts
5254
FAIL ./import-default.spec.ts
@@ -67,8 +69,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru
6769
6870
at Object.<anonymous> (import-default.spec.ts:4:22)
6971
70-
Test Suites: 1 failed, 2 passed, 3 total
71-
Tests: 1 failed, 2 passed, 3 total
72+
Test Suites: 1 failed, 3 passed, 4 total
73+
Tests: 1 failed, 4 passed, 5 total
7274
Snapshots: 0 total
7375
Time: XXs
7476
Ran all test suites.
@@ -81,6 +83,7 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = `
8183
===[ STDOUT ]===================================================================
8284
8385
===[ STDERR ]===================================================================
86+
PASS ./ts-jest-tools.spec.ts
8487
PASS ./import-legacy.spec.ts
8588
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
8689
import-star.spec.ts:5:10 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof lib' has no compatible call signatures.
@@ -112,8 +115,8 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = `
112115
113116
PASS ./import-default.spec.ts
114117
115-
Test Suites: 1 failed, 2 passed, 3 total
116-
Tests: 1 failed, 2 passed, 3 total
118+
Test Suites: 1 failed, 3 passed, 4 total
119+
Tests: 1 failed, 4 passed, 5 total
117120
Snapshots: 0 total
118121
Time: XXs
119122
Ran all test suites.
@@ -128,6 +131,7 @@ exports[`run with options: {"module":"es2015"} 1`] = `
128131
===[ STDERR ]===================================================================
129132
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
130133
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.
134+
PASS ./ts-jest-tools.spec.ts
131135
PASS ./import-legacy.spec.ts
132136
PASS ./import-star.spec.ts
133137
FAIL ./import-default.spec.ts
@@ -148,8 +152,8 @@ exports[`run with options: {"module":"es2015"} 1`] = `
148152
149153
at Object.<anonymous> (import-default.spec.ts:4:22)
150154
151-
Test Suites: 1 failed, 2 passed, 3 total
152-
Tests: 1 failed, 2 passed, 3 total
155+
Test Suites: 1 failed, 3 passed, 4 total
156+
Tests: 1 failed, 4 passed, 5 total
153157
Snapshots: 0 total
154158
Time: XXs
155159
Ran all test suites.

e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal
88
===[ STDERR ]===================================================================
99
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
1010
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.
11+
PASS ./ts-jest-tools.spec.ts
1112
PASS ./import-legacy.spec.ts
1213
PASS ./import-star.spec.ts
1314
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
@@ -33,8 +34,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal
3334
3435
at Object.<anonymous> (import-default.spec.ts:4:22)
3536
36-
Test Suites: 1 failed, 2 passed, 3 total
37-
Tests: 1 failed, 2 passed, 3 total
37+
Test Suites: 1 failed, 3 passed, 4 total
38+
Tests: 1 failed, 4 passed, 5 total
3839
Snapshots: 0 total
3940
Time: XXs
4041
Ran all test suites.
@@ -47,6 +48,7 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":tru
4748
===[ STDOUT ]===================================================================
4849
4950
===[ STDERR ]===================================================================
51+
PASS ./ts-jest-tools.spec.ts
5052
PASS ./import-legacy.spec.ts
5153
PASS ./import-star.spec.ts
5254
FAIL ./import-default.spec.ts
@@ -67,8 +69,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":tru
6769
6870
at Object.<anonymous> (import-default.spec.ts:4:22)
6971
70-
Test Suites: 1 failed, 2 passed, 3 total
71-
Tests: 1 failed, 2 passed, 3 total
72+
Test Suites: 1 failed, 3 passed, 4 total
73+
Tests: 1 failed, 4 passed, 5 total
7274
Snapshots: 0 total
7375
Time: XXs
7476
Ran all test suites.
@@ -81,6 +83,7 @@ exports[`run with options: {"module":"esnext","esModuleInterop":true} 1`] = `
8183
===[ STDOUT ]===================================================================
8284
8385
===[ STDERR ]===================================================================
86+
PASS ./ts-jest-tools.spec.ts
8487
PASS ./import-legacy.spec.ts
8588
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
8689
import-star.spec.ts:5:10 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof lib' has no compatible call signatures.
@@ -112,8 +115,8 @@ exports[`run with options: {"module":"esnext","esModuleInterop":true} 1`] = `
112115
113116
PASS ./import-default.spec.ts
114117
115-
Test Suites: 1 failed, 2 passed, 3 total
116-
Tests: 1 failed, 2 passed, 3 total
118+
Test Suites: 1 failed, 3 passed, 4 total
119+
Tests: 1 failed, 4 passed, 5 total
117120
Snapshots: 0 total
118121
Time: XXs
119122
Ran all test suites.
@@ -128,6 +131,7 @@ exports[`run with options: {"module":"esnext"} 1`] = `
128131
===[ STDERR ]===================================================================
129132
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
130133
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.
134+
PASS ./ts-jest-tools.spec.ts
131135
PASS ./import-legacy.spec.ts
132136
PASS ./import-star.spec.ts
133137
FAIL ./import-default.spec.ts
@@ -148,8 +152,8 @@ exports[`run with options: {"module":"esnext"} 1`] = `
148152
149153
at Object.<anonymous> (import-default.spec.ts:4:22)
150154
151-
Test Suites: 1 failed, 2 passed, 3 total
152-
Tests: 1 failed, 2 passed, 3 total
155+
Test Suites: 1 failed, 3 passed, 4 total
156+
Tests: 1 failed, 4 passed, 5 total
153157
Snapshots: 0 total
154158
Time: XXs
155159
Ran all test suites.

0 commit comments

Comments
 (0)