Skip to content

Commit 0807967

Browse files
committed
fix(compiler): use resolveModuleNames TypeScript API
1 parent 5da0da1 commit 0807967

23 files changed

Lines changed: 356 additions & 308 deletions

File tree

File renamed without changes.

e2e/__cases__/diagnostics/warn/main.spec.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

e2e/__cases__/diagnostics/warn/main.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

e2e/__cases__/test-helpers/deprecated.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mocked } from 'ts-jest'
2-
import { foo } from './to-mock'
3-
jest.mock('./to-mock')
2+
import { foo } from './pass-to-mock'
3+
jest.mock('./pass-to-mock')
44

55
test('foo', () => {
66
foo()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const foo = () => 'foo'
2+
3+
export function bar() {
4+
return 'bar'
5+
}
6+
export namespace bar {
7+
export function dummy() {
8+
return 'dummy'
9+
}
10+
export namespace dummy {
11+
export const deep = {
12+
deeper: (one: string = '1') => `deeper ${one}`
13+
}
14+
}
15+
}
16+
17+
export class MyClass {
18+
constructor(s: string) {
19+
this.myProperty = 3
20+
this.myStr = s
21+
}
22+
somethingClassy() { return this.myStr }
23+
public myProperty: number;
24+
public myStr: string;
25+
}

e2e/__cases__/test-helpers/pass.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mocked } from 'ts-jest/utils'
2-
import { foo, bar, MyClass } from './to-mock'
3-
jest.mock('./to-mock')
2+
import { foo, bar, MyClass } from './pass-to-mock'
3+
jest.mock('./pass-to-mock')
44

55
test('foo', () => {
66
// real returns 'foo', mocked returns 'bar'

e2e/__tests__/__snapshots__/diagnostics.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`With diagnostics throw should fail using template "default" 1`] = `
4-
× jest
4+
× jest --no-cache
55
↳ exit code: 1
66
===[ STDOUT ]===================================================================
77
@@ -28,7 +28,7 @@ exports[`With diagnostics throw should fail using template "default" 1`] = `
2828
`;
2929

3030
exports[`With diagnostics throw should fail using template "with-babel-7" 1`] = `
31-
× jest
31+
× jest --no-cache
3232
↳ exit code: 1
3333
===[ STDOUT ]===================================================================
3434
@@ -55,7 +55,7 @@ exports[`With diagnostics throw should fail using template "with-babel-7" 1`] =
5555
`;
5656

5757
exports[`With diagnostics throw should fail using template "with-babel-7-string-config" 1`] = `
58-
× jest
58+
× jest --no-cache
5959
↳ exit code: 1
6060
===[ STDOUT ]===================================================================
6161

e2e/__tests__/__snapshots__/logger.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Array [
2626
"[level:20] compileFn(): compiling using language service",
2727
"[level:20] updateMemoryCache(): update memory cache for language service",
2828
"[level:20] visitSourceFileNode(): hoisting",
29-
"[level:20] compileFn(): computing diagnostics using language service",
29+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
3030
"[level:20] computing cache key for <cwd>/Hello.ts",
3131
"[level:20] processing <cwd>/Hello.ts",
3232
"[level:20] compileAndUpdateOutput(): get compile output",
3333
"[level:20] compileFn(): compiling using language service",
3434
"[level:20] updateMemoryCache(): update memory cache for language service",
3535
"[level:20] visitSourceFileNode(): hoisting",
36-
"[level:20] compileFn(): computing diagnostics using language service",
36+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
3737
]
3838
`;
3939
@@ -67,15 +67,15 @@ Array [
6767
"[level:20] compileFn(): compiling using language service",
6868
"[level:20] updateMemoryCache(): update memory cache for language service",
6969
"[level:20] visitSourceFileNode(): hoisting",
70-
"[level:20] compileFn(): computing diagnostics using language service",
70+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
7171
"[level:20] calling babel-jest processor",
7272
"[level:20] computing cache key for <cwd>/Hello.ts",
7373
"[level:20] processing <cwd>/Hello.ts",
7474
"[level:20] compileAndUpdateOutput(): get compile output",
7575
"[level:20] compileFn(): compiling using language service",
7676
"[level:20] updateMemoryCache(): update memory cache for language service",
7777
"[level:20] visitSourceFileNode(): hoisting",
78-
"[level:20] compileFn(): computing diagnostics using language service",
78+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
7979
"[level:20] calling babel-jest processor",
8080
]
8181
`;
@@ -111,15 +111,15 @@ Array [
111111
"[level:20] compileFn(): compiling using language service",
112112
"[level:20] updateMemoryCache(): update memory cache for language service",
113113
"[level:20] visitSourceFileNode(): hoisting",
114-
"[level:20] compileFn(): computing diagnostics using language service",
114+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
115115
"[level:20] calling babel-jest processor",
116116
"[level:20] computing cache key for <cwd>/Hello.ts",
117117
"[level:20] processing <cwd>/Hello.ts",
118118
"[level:20] compileAndUpdateOutput(): get compile output",
119119
"[level:20] compileFn(): compiling using language service",
120120
"[level:20] updateMemoryCache(): update memory cache for language service",
121121
"[level:20] visitSourceFileNode(): hoisting",
122-
"[level:20] compileFn(): computing diagnostics using language service",
122+
"[level:20] compileFn(): computing diagnostics using language service for resolved module",
123123
"[level:20] calling babel-jest processor",
124124
]
125125
`;

e2e/__tests__/diagnostics.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { allValidPackageSets } from '../__helpers__/templates'
22
import { configureTestCase } from '../__helpers__/test-case'
33

44
describe('With diagnostics throw', () => {
5-
const testCase = configureTestCase('diagnostics/throw')
5+
const testCase = configureTestCase('diagnostics', {
6+
noCache: true, // warnings shown only on first compilation
7+
})
68

79
testCase.runWithTemplates(allValidPackageSets, 1, (runTest, { testLabel }) => {
810
it(testLabel, () => {
@@ -14,7 +16,7 @@ describe('With diagnostics throw', () => {
1416
})
1517

1618
describe('With diagnostics warn only', () => {
17-
const testCase = configureTestCase('diagnostics/warn', {
19+
const testCase = configureTestCase('diagnostics', {
1820
tsJestConfig: {
1921
diagnostics: { warnOnly: true },
2022
},

0 commit comments

Comments
 (0)