Fix jest tests

This commit is contained in:
William Monk
2017-05-22 15:15:37 +01:00
parent 45c7c1418e
commit b9b585f147
4 changed files with 12 additions and 26 deletions

View File

@@ -1,16 +0,0 @@
// @remove-file-on-eject
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const babelJest = require('babel-jest');
module.exports = babelJest.createTransformer({
presets: [require.resolve('babel-preset-react-app')],
babelrc: false,
});

View File

@@ -23,6 +23,7 @@
},
"dependencies": {
"autoprefixer": "7.1.0",
"app-root-path": "^2.0.1",
"case-sensitive-paths-webpack-plugin": "2.0.0",
"chalk": "1.1.3",
"cli-highlight": "1.1.4",

View File

@@ -13,7 +13,7 @@ const fs = require('fs');
const chalk = require('chalk');
const paths = require('../../config/paths');
module.exports = (resolve, rootDir, isEjecting) => {
module.exports = (resolve, rootDir) => {
// Use this instead of `paths.testsSetup` to avoid putting
// an absolute filename into configuration after ejecting.
const setupTestsFile = fs.existsSync(paths.testsSetup)
@@ -23,23 +23,24 @@ module.exports = (resolve, rootDir, isEjecting) => {
// TODO: I don't know if it's safe or not to just use / as path separator
// in Jest configs. We need help from somebody with Windows to determine this.
const config = {
collectCoverageFrom: ['src/**/*.{js,jsx}'],
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
setupFiles: [resolve('config/polyfills.js')],
setupTestFrameworkScriptFile: setupTestsFile,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.js?(x)',
'<rootDir>/src/**/?(*.)(spec|test).js?(x)',
'<rootDir>/src/**/__tests__/**/*.ts?(x)',
'<rootDir>/src/**/?(*.)(spec|test).ts?(x)',
],
testEnvironment: 'node',
testURL: 'http://localhost',
transform: {
'^.+\\.(js|jsx)$': isEjecting
? '<rootDir>/node_modules/babel-jest'
: resolve('config/jest/babelTransform.js'),
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
'^.+\\.tsx?$': resolve('config/jest/typescriptTransform.js'),
'^(?!.*\\.(css|json)$)': resolve('config/jest/fileTransform.js'),
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tssx)$',
],
moduleNameMapper: {
'^react-native$': 'react-native-web',
},

View File

@@ -285,7 +285,7 @@ echo yes | npm run eject
npm link "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts-ts
npm link "$root_path"/packages/react-scripts
# Test the build
npm run build