@@ -13,7 +13,7 @@ const fs = require('fs');
13
13
const chalk = require ( 'chalk' ) ;
14
14
const paths = require ( '../../config/paths' ) ;
15
15
16
- module . exports = ( resolve , rootDir , isEjecting ) => {
16
+ module . exports = ( resolve , rootDir ) => {
17
17
// Use this instead of `paths.testsSetup` to avoid putting
18
18
// an absolute filename into configuration after ejecting.
19
19
const setupTestsFile = fs . existsSync ( paths . testsSetup )
@@ -23,23 +23,24 @@ module.exports = (resolve, rootDir, isEjecting) => {
23
23
// TODO: I don't know if it's safe or not to just use / as path separator
24
24
// in Jest configs. We need help from somebody with Windows to determine this.
25
25
const config = {
26
- collectCoverageFrom : [ 'src/**/*.{js,jsx}' ] ,
26
+ collectCoverageFrom : [ 'src/**/*.{js,jsx,ts,tsx }' ] ,
27
27
setupFiles : [ resolve ( 'config/polyfills.js' ) ] ,
28
28
setupTestFrameworkScriptFile : setupTestsFile ,
29
+ moduleFileExtensions : [ 'ts' , 'tsx' , 'js' , 'jsx' ] ,
29
30
testMatch : [
30
- '<rootDir>/src/**/__tests__/**/*.js ?(x)' ,
31
- '<rootDir>/src/**/?(*.)(spec|test).js ?(x)' ,
31
+ '<rootDir>/src/**/__tests__/**/*.ts ?(x)' ,
32
+ '<rootDir>/src/**/?(*.)(spec|test).ts ?(x)' ,
32
33
] ,
33
34
testEnvironment : 'node' ,
34
35
testURL : 'http://localhost' ,
35
36
transform : {
36
- '^.+\\.(js|jsx)$' : isEjecting
37
- ? '<rootDir>/node_modules/babel-jest'
38
- : resolve ( 'config/jest/babelTransform.js' ) ,
39
37
'^.+\\.css$' : resolve ( 'config/jest/cssTransform.js' ) ,
40
- '^(?!.*\\.(js|jsx|css|json)$)' : resolve ( 'config/jest/fileTransform.js' ) ,
38
+ '^.+\\.tsx?$' : resolve ( 'config/jest/typescriptTransform.js' ) ,
39
+ '^(?!.*\\.(css|json)$)' : resolve ( 'config/jest/fileTransform.js' ) ,
41
40
} ,
42
- transformIgnorePatterns : [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$' ] ,
41
+ transformIgnorePatterns : [
42
+ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tssx)$' ,
43
+ ] ,
43
44
moduleNameMapper : {
44
45
'^react-native$' : 'react-native-web' ,
45
46
} ,
0 commit comments