Skip to content

Commit

Permalink
chore(config): improve diagnostics message (#1444)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This will affect to any snapshots or assertion against diagnostics messages
  • Loading branch information
ahnpnl authored Mar 25, 2020
1 parent 57c8f3e commit 96cd9b3
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 126 deletions.
18 changes: 6 additions & 12 deletions e2e/__tests__/__snapshots__/compiler-host.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ exports[`With compilerHost enabled and incremental disabled should pass using te
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand All @@ -71,8 +70,7 @@ exports[`With compilerHost enabled and incremental disabled should pass using te
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand All @@ -93,8 +91,7 @@ exports[`With compilerHost enabled and incremental disabled should pass using te
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand Down Expand Up @@ -158,8 +155,7 @@ exports[`With compilerHost enabled and incremental enabled should pass using tem
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand All @@ -180,8 +176,7 @@ exports[`With compilerHost enabled and incremental enabled should pass using tem
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand All @@ -202,8 +197,7 @@ exports[`With compilerHost enabled and incremental enabled should pass using tem
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
ts-jest[ts-compiler] (WARN) main.spec.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'.
4 const x: string = g(5)
~
Expand Down
16 changes: 4 additions & 12 deletions e2e/__tests__/__snapshots__/diagnostics.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`With diagnostics, first throws should fail using template "default" 1`]
FAIL ./main.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
Expand All @@ -32,7 +31,6 @@ exports[`With diagnostics, first throws should fail using template "with-babel-7
FAIL ./main.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
Expand All @@ -55,7 +53,6 @@ exports[`With diagnostics, first throws should fail using template "with-babel-7
FAIL ./main.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
Expand All @@ -78,7 +75,6 @@ exports[`With diagnostics, first throws should fail using template "with-typescr
FAIL ./main.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
Expand All @@ -98,8 +94,7 @@ exports[`With diagnostics, warn only should pass using template "default" 1`] =
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
ts-jest[ts-compiler] (WARN) main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
~~~~~~~~~~~~
Expand All @@ -120,8 +115,7 @@ exports[`With diagnostics, warn only should pass using template "with-babel-7" 1
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
ts-jest[ts-compiler] (WARN) main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
~~~~~~~~~~~~
Expand All @@ -142,8 +136,7 @@ exports[`With diagnostics, warn only should pass using template "with-babel-7-st
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
ts-jest[ts-compiler] (WARN) main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
~~~~~~~~~~~~
Expand All @@ -164,8 +157,7 @@ exports[`With diagnostics, warn only should pass using template "with-typescript
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
ts-jest[ts-compiler] (WARN) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
ts-jest[ts-compiler] (WARN) main.ts:2:3 - error TS2322: Type 'string' is not assignable to type 'number'.
2 return input
~~~~~~~~~~~~
Expand Down
2 changes: 0 additions & 2 deletions e2e/__tests__/__snapshots__/test-helpers.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ exports[`test-helpers 1`] = `
FAIL ./fail.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
fail.spec.ts:7:22 - error TS2554: Expected 0 arguments, but got 1.
7 expect(mocked(foo)('hello')).toBeUndefined()
Expand Down Expand Up @@ -41,7 +40,6 @@ exports[`with esModuleInterop set to false 1`] = `
FAIL ./fail.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
fail.spec.ts:7:22 - error TS2554: Expected 0 arguments, but got 1.
7 expect(mocked(foo)('hello')).toBeUndefined()
Expand Down
15 changes: 5 additions & 10 deletions e2e/__tests__/module-kinds/__snapshots__/amd.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ exports[`run with options: {"module":"amd","allowSyntheticDefaultImports":false}
===[ STDOUT ]===================================================================
===[ 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.
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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
import-default.spec.ts:1:8 - error TS1259: Module '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
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
1 import lib from './lib'
~~~
Expand Down Expand Up @@ -88,8 +86,7 @@ exports[`run with options: {"module":"amd","esModuleInterop":false} 1`] = `
===[ STDOUT ]===================================================================
===[ 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.
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
Expand Down Expand Up @@ -127,8 +124,7 @@ exports[`run with options: {"module":"amd","esModuleInterop":true} 1`] = `
===[ 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: This expression is not callable.
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.
5 expect(lib()).toBe('foo')
Expand Down Expand Up @@ -172,8 +168,7 @@ exports[`run with options: {"module":"amd"} 1`] = `
===[ STDOUT ]===================================================================
===[ 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.
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
Expand Down
12 changes: 4 additions & 8 deletions e2e/__tests__/module-kinds/__snapshots__/commonjs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ exports[`run with options: {"module":"commonjs","allowSyntheticDefaultImports":f
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):
import-default.spec.ts:1:8 - error TS1259: Module '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
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
1 import lib from './lib'
~~~
Expand Down Expand Up @@ -89,8 +88,7 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":false} 1`] = `
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):
import-default.spec.ts:1:8 - error TS1259: Module '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
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
1 import lib from './lib'
~~~
Expand Down Expand Up @@ -133,8 +131,7 @@ exports[`run with options: {"module":"commonjs","esModuleInterop":true} 1`] = `
===[ 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: This expression is not callable.
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.
5 expect(lib()).toBe('foo')
Expand Down Expand Up @@ -181,8 +178,7 @@ exports[`run with options: {"module":"commonjs"} 1`] = `
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):
import-default.spec.ts:1:8 - error TS1259: Module '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
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
1 import lib from './lib'
~~~
Expand Down
15 changes: 5 additions & 10 deletions e2e/__tests__/module-kinds/__snapshots__/es2015.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ exports[`run with options: {"module":"es2015","allowSyntheticDefaultImports":fal
===[ STDOUT ]===================================================================
===[ 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.
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) TypeScript diagnostics (customize using \`[jest-config].globals.ts-jest.diagnostics\` option):
import-default.spec.ts:1:8 - error TS1259: Module '"<cwd>/lib"' can only be default-imported using the 'esModuleInterop' flag
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
1 import lib from './lib'
~~~
Expand Down Expand Up @@ -88,8 +86,7 @@ exports[`run with options: {"module":"es2015","esModuleInterop":false} 1`] = `
===[ STDOUT ]===================================================================
===[ 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.
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
Expand Down Expand Up @@ -127,8 +124,7 @@ exports[`run with options: {"module":"es2015","esModuleInterop":true} 1`] = `
===[ 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: This expression is not callable.
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.
5 expect(lib()).toBe('foo')
Expand Down Expand Up @@ -172,8 +168,7 @@ exports[`run with options: {"module":"es2015"} 1`] = `
===[ STDOUT ]===================================================================
===[ 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.
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
Expand Down
Loading

0 comments on commit 96cd9b3

Please sign in to comment.