2
2
3
3
const { jsWithTs : preset } = require ( 'ts-jest/presets' )
4
4
5
- const { ifAnyDep, hasAnyDep , hasFile, fromRoot} = require ( '../utils' )
5
+ const { ifAnyDep, hasFile, fromRoot} = require ( '../utils' )
6
6
7
7
const {
8
8
testMatch,
@@ -29,6 +29,14 @@ const jestConfig = {
29
29
testMatch,
30
30
testPathIgnorePatterns : [ ...ignores , '<rootDir>/dist' ] ,
31
31
testLocationInResults : true ,
32
+ transform : Object . fromEntries (
33
+ // Ensure we can resolve the preset even when
34
+ // it's in a nested `node_modules` installation
35
+ Object . entries ( preset . transform ) . map ( ( [ key , value ] ) => [
36
+ key ,
37
+ require . resolve ( value ) ,
38
+ ] ) ,
39
+ ) ,
32
40
coveragePathIgnorePatterns : [
33
41
...ignores ,
34
42
'src/(umd|cjs|esm)-entry.js$' ,
@@ -51,24 +59,13 @@ const jestConfig = {
51
59
require . resolve ( 'jest-watch-typeahead/filename' ) ,
52
60
require . resolve ( 'jest-watch-typeahead/testname' ) ,
53
61
] ,
54
- globals : { } ,
55
- }
56
-
57
- if ( hasAnyDep ( 'ts-jest' ) || hasFile ( 'tsconfig.json' ) ) {
58
- jestConfig . transform = Object . fromEntries (
59
- // Ensure we can resolve the preset even when
60
- // it's in a nested `node_modules` installation
61
- Object . entries ( preset . transform ) . map ( ( [ key , value ] ) => [
62
- key ,
63
- require . resolve ( value ) ,
64
- ] ) ,
65
- )
66
-
67
- jestConfig . globals [ 'ts-jest' ] = {
68
- diagnostics : {
69
- warnOnly : true ,
62
+ globals : {
63
+ 'ts-jest' : {
64
+ diagnostics : {
65
+ warnOnly : true ,
66
+ } ,
70
67
} ,
71
- }
68
+ } ,
72
69
}
73
70
74
71
if ( hasFile ( 'tests/setup-env.js' ) ) {
0 commit comments