Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit b9b585f

Browse files
author
William Monk
committed
Fix jest tests
1 parent 45c7c14 commit b9b585f

File tree

4 files changed

+12
-26
lines changed

4 files changed

+12
-26
lines changed

packages/react-scripts/config/jest/babelTransform.js

-16
This file was deleted.

packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
},
2424
"dependencies": {
2525
"autoprefixer": "7.1.0",
26+
"app-root-path": "^2.0.1",
2627
"case-sensitive-paths-webpack-plugin": "2.0.0",
2728
"chalk": "1.1.3",
2829
"cli-highlight": "1.1.4",

packages/react-scripts/scripts/utils/createJestConfig.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fs = require('fs');
1313
const chalk = require('chalk');
1414
const paths = require('../../config/paths');
1515

16-
module.exports = (resolve, rootDir, isEjecting) => {
16+
module.exports = (resolve, rootDir) => {
1717
// Use this instead of `paths.testsSetup` to avoid putting
1818
// an absolute filename into configuration after ejecting.
1919
const setupTestsFile = fs.existsSync(paths.testsSetup)
@@ -23,23 +23,24 @@ module.exports = (resolve, rootDir, isEjecting) => {
2323
// TODO: I don't know if it's safe or not to just use / as path separator
2424
// in Jest configs. We need help from somebody with Windows to determine this.
2525
const config = {
26-
collectCoverageFrom: ['src/**/*.{js,jsx}'],
26+
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
2727
setupFiles: [resolve('config/polyfills.js')],
2828
setupTestFrameworkScriptFile: setupTestsFile,
29+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
2930
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)',
3233
],
3334
testEnvironment: 'node',
3435
testURL: 'http://localhost',
3536
transform: {
36-
'^.+\\.(js|jsx)$': isEjecting
37-
? '<rootDir>/node_modules/babel-jest'
38-
: resolve('config/jest/babelTransform.js'),
3937
'^.+\\.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'),
4140
},
42-
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
41+
transformIgnorePatterns: [
42+
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tssx)$',
43+
],
4344
moduleNameMapper: {
4445
'^react-native$': 'react-native-web',
4546
},

tasks/e2e-simple.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ echo yes | npm run eject
285285
npm link "$root_path"/packages/babel-preset-react-app
286286
npm link "$root_path"/packages/eslint-config-react-app
287287
npm link "$root_path"/packages/react-dev-utils
288-
npm link "$root_path"/packages/react-scripts-ts
288+
npm link "$root_path"/packages/react-scripts
289289

290290
# Test the build
291291
npm run build

0 commit comments

Comments
 (0)