Skip to content

Commit

Permalink
fix(typings): wrong import in preset typings + test
Browse files Browse the repository at this point in the history
  • Loading branch information
huafu committed Oct 6, 2018
1 parent 53767ab commit 94dc4e7
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 57 deletions.
21 changes: 21 additions & 0 deletions e2e/__cases__/module-kinds/ts-jest-tools.spec.ts
@@ -0,0 +1,21 @@
// 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', 'testMatch', 'moduleFileExtensions']
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')
})
20 changes: 12 additions & 8 deletions e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap
Expand Up @@ -8,6 +8,7 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
Expand All @@ -33,8 +34,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -47,6 +48,7 @@ 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 @@ -67,8 +69,8 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":true}
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -81,6 +83,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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.
Expand Down Expand Up @@ -112,8 +115,8 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = `
PASS ./import-default.spec.ts
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -128,6 +131,7 @@ exports[`run with options: {"module":"amd"} 1`] = `
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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 @@ -148,8 +152,8 @@ exports[`run with options: {"module":"amd"} 1`] = `
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand Down
20 changes: 12 additions & 8 deletions e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap
Expand Up @@ -6,6 +6,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
Expand All @@ -31,8 +32,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -45,6 +46,7 @@ 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 @@ -65,8 +67,8 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":t
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -79,6 +81,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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.
Expand Down Expand Up @@ -110,8 +113,8 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = `
PASS ./import-default.spec.ts
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -124,6 +127,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
Expand All @@ -149,8 +153,8 @@ exports[`run with options: {"module":"commonjs"} 1`] = `
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand Down
20 changes: 12 additions & 8 deletions e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap
Expand Up @@ -8,6 +8,7 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
Expand All @@ -33,8 +34,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -47,6 +48,7 @@ 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 @@ -67,8 +69,8 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":tru
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -81,6 +83,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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.
Expand Down Expand Up @@ -112,8 +115,8 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = `
PASS ./import-default.spec.ts
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -128,6 +131,7 @@ exports[`run with options: {"module":"es2015"} 1`] = `
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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 @@ -148,8 +152,8 @@ exports[`run with options: {"module":"es2015"} 1`] = `
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand Down
20 changes: 12 additions & 8 deletions e2e/__tests__/module-kinds/__snapshots__/esnext.test.ts.snap
Expand Up @@ -8,6 +8,7 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
Expand All @@ -33,8 +34,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":fal
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -47,6 +48,7 @@ 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
Expand All @@ -67,8 +69,8 @@ exports[`run with options: {"module":"esnext","allowSyntheticDefaultImports":tru
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -81,6 +83,7 @@ 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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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.
Expand Down Expand Up @@ -112,8 +115,8 @@ exports[`run with options: {"module":"esnext","esModuleInterop":true} 1`] = `
PASS ./import-default.spec.ts
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand All @@ -128,6 +131,7 @@ exports[`run with options: {"module":"esnext"} 1`] = `
===[ STDERR ]===================================================================
ts-jest[config] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
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 @@ -148,8 +152,8 @@ exports[`run with options: {"module":"esnext"} 1`] = `
at Object.<anonymous> (import-default.spec.ts:4:22)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 1 failed, 2 passed, 3 total
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
Expand Down

0 comments on commit 94dc4e7

Please sign in to comment.