@@ -15,31 +15,34 @@ module.exports = (resolve, rootDir, isEjecting) => {
15
15
// Use this instead of `paths.testsSetup` to avoid putting
16
16
// an absolute filename into configuration after ejecting.
17
17
const setupTestsFile = fs . existsSync ( paths . testsSetup )
18
- ? '<rootDir>/src/setupTests.js '
18
+ ? '<rootDir>/src/setupTests.ts '
19
19
: undefined ;
20
20
21
21
// TODO: I don't know if it's safe or not to just use / as path separator
22
22
// in Jest configs. We need help from somebody with Windows to determine this.
23
23
const config = {
24
- collectCoverageFrom : [ 'src/**/*.{js,jsx,mjs}' ] ,
24
+ collectCoverageFrom : [ 'src/**/*.{js,jsx,mjs,ts,tsx }' ] ,
25
25
setupFiles : [ resolve ( 'config/polyfills.js' ) ] ,
26
26
setupTestFrameworkScriptFile : setupTestsFile ,
27
27
testMatch : [
28
- '<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}' ,
29
- '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}' ,
28
+ '<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs,ts,tsx }' ,
29
+ '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs,ts,tsx }' ,
30
30
] ,
31
31
testEnvironment : 'node' ,
32
32
testURL : 'http://localhost' ,
33
33
transform : {
34
34
'^.+\\.(js|jsx|mjs)$' : isEjecting
35
35
? '<rootDir>/node_modules/babel-jest'
36
36
: resolve ( 'config/jest/babelTransform.js' ) ,
37
+ '^.+\\.tsx?$' : resolve ( 'config/jest/typescriptTransform.js' ) ,
37
38
'^.+\\.css$' : resolve ( 'config/jest/cssTransform.js' ) ,
38
39
'^(?!.*\\.(js|jsx|mjs|css|json)$)' : resolve (
39
40
'config/jest/fileTransform.js'
40
41
) ,
41
42
} ,
42
- transformIgnorePatterns : [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$' ] ,
43
+ transformIgnorePatterns : [
44
+ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$' ,
45
+ ] ,
43
46
moduleNameMapper : {
44
47
'^react-native$' : 'react-native-web' ,
45
48
} ,
@@ -51,7 +54,16 @@ module.exports = (resolve, rootDir, isEjecting) => {
51
54
'jsx' ,
52
55
'node' ,
53
56
'mjs' ,
57
+ 'web.ts' ,
58
+ 'ts' ,
59
+ 'web.tsx' ,
60
+ 'tsx' ,
54
61
] ,
62
+ globals : {
63
+ 'ts-jest' : {
64
+ tsConfigFile : paths . appTsTestConfig ,
65
+ } ,
66
+ } ,
55
67
} ;
56
68
if ( rootDir ) {
57
69
config . rootDir = rootDir ;
0 commit comments