Skip to content

Commit 4bc7ead

Browse files
author
Josh Sylvester
authored
Merge pull request #13 from shinxi/MAX-5172
MAX-5172 CRA unable to run tests after install
2 parents c7b501e + b369a92 commit 4bc7ead

File tree

13 files changed

+50
-7741
lines changed

13 files changed

+50
-7741
lines changed

packages/react-scripts/config/paths.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
appPackageJson: resolveApp('package.json'),
5959
appSrc: resolveApp('src'),
6060
yarnLockFile: resolveApp('yarn.lock'),
61-
testsSetup: resolveApp('src/setupTests.js'),
61+
testsSetup: resolveApp('src/test/jest-setup.js'),
6262
appNodeModules: resolveApp('node_modules'),
6363
publicUrl: getPublicUrl(resolveApp('package.json')),
6464
servedPath: getServedPath(resolveApp('package.json')),
@@ -78,7 +78,7 @@ module.exports = {
7878
appPackageJson: resolveApp('package.json'),
7979
appSrc: resolveApp('src'),
8080
yarnLockFile: resolveApp('yarn.lock'),
81-
testsSetup: resolveApp('src/setupTests.js'),
81+
testsSetup: resolveApp('src/test/jest-setup.js'),
8282
appNodeModules: resolveApp('node_modules'),
8383
publicUrl: getPublicUrl(resolveApp('package.json')),
8484
servedPath: getServedPath(resolveApp('package.json')),
@@ -108,7 +108,7 @@ if (
108108
appPackageJson: resolveOwn('package.json'),
109109
appSrc: resolveOwn('template/src'),
110110
yarnLockFile: resolveOwn('template/yarn.lock'),
111-
testsSetup: resolveOwn('template/src/setupTests.js'),
111+
testsSetup: resolveOwn('template/src/test/jest-setup.js'),
112112
appNodeModules: resolveOwn('node_modules'),
113113
publicUrl: getPublicUrl(resolveOwn('package.json')),
114114
servedPath: getServedPath(resolveOwn('package.json')),

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
const autoprefixer = require('autoprefixer');
14+
const fs = require('fs');
1415
const path = require('path');
1516
const webpack = require('webpack');
1617
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -33,6 +34,8 @@ const publicUrl = '';
3334
// Get environment variables to inject into our app.
3435
const env = getClientEnvironment(publicUrl);
3536

37+
const containUIComponents = fs.existsSync(path.resolve(paths.appNodeModules, "@svmx/ui-components-predix/bower_components"));
38+
3639
// This is the development configuration.
3740
// It is focused on developer experience and fast rebuilds.
3841
// The production configuration is different and lives in a separate file.
@@ -259,7 +262,8 @@ module.exports = {
259262
new InterpolateHtmlPlugin(env.raw),
260263
// Generates an `index.html` file with the <script> injected.
261264
new HtmlWebpackPlugin({
262-
inject: false,
265+
inject: !containUIComponents,
266+
containUIComponents: containUIComponents,
263267
template: paths.appHtml,
264268
}),
265269
// Add module names to factory functions so they appear in browser profiler.
@@ -286,7 +290,8 @@ module.exports = {
286290
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
287291
new CopyWebpackPlugin([
288292
{
289-
from: 'node_modules/@svmx/ui-components-predix/bower_components',
293+
context: path.resolve(paths.appNodeModules, "@svmx/ui-components-predix/bower_components"),
294+
from: '**/*',
290295
to: 'bower_components',
291296
},
292297
])

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
const autoprefixer = require('autoprefixer');
14+
const fs = require('fs');
1415
const path = require('path');
1516
const webpack = require('webpack');
1617
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -39,6 +40,8 @@ const publicUrl = publicPath.slice(0, -1);
3940
// Get environment variables to inject into our app.
4041
const env = getClientEnvironment(publicUrl);
4142

43+
const containUIComponents = fs.existsSync(path.resolve(paths.appNodeModules, "@svmx/ui-components-predix/bower_components"));
44+
4245
// Assert this just to be safe.
4346
// Development builds of React are slow and not intended for production.
4447
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
@@ -279,8 +282,8 @@ module.exports = {
279282
new InterpolateHtmlPlugin(env.raw),
280283
// Generates an `index.html` file with the <script> injected.
281284
new HtmlWebpackPlugin({
282-
inject: false,
283-
template: paths.appHtml,
285+
inject: !containUIComponents,
286+
containUIComponents: containUIComponents,
284287
minify: {
285288
removeComments: true,
286289
collapseWhitespace: true,
@@ -365,7 +368,8 @@ module.exports = {
365368
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
366369
new CopyWebpackPlugin([
367370
{
368-
from: 'node_modules/@svmx/ui-components-predix/bower_components',
371+
context: path.resolve(paths.appNodeModules, "@svmx/ui-components-predix/bower_components"),
372+
from: '**/*',
369373
to: 'bower_components',
370374
},
371375
])

packages/react-scripts/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"copy-webpack-plugin": "^4.2.0",
4040
"css-loader": "0.28.4",
4141
"dotenv": "4.0.0",
42-
"enzyme": "2.9.0",
42+
"enzyme": "^3.1.0",
43+
"enzyme-adapter-react-16": "^1.0.2",
4344
"eslint": "~4.7.1",
4445
"eslint-config-airbnb": "^15.1.0",
4546
"eslint-config-react-app": "2.0.0",
@@ -66,7 +67,7 @@
6667
"react-error-overlay": "1.0.6",
6768
"react-router": "^4.2.0",
6869
"react-router-dom": "^4.2.2",
69-
"react-test-renderer": "15.6.1",
70+
"react-test-renderer": "16.0.0",
7071
"sass-loader": "6.0.6",
7172
"style-loader": "0.18.2",
7273
"sw-precache-webpack-plugin": "0.11.4",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
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)
20-
? '<rootDir>/src/setupTests.js'
20+
? '<rootDir>/src/test/jest-setup.js'
2121
: undefined;
2222

2323
// TODO: I don't know if it's safe or not to just use / as path separator

packages/react-scripts/template/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"sourceType": "module"
1616
},
1717
"rules": {
18+
"arrow-parens": "off", // Incompatible with prettier
1819
"no-unused-vars": "warn",
1920
"no-debugger": "warn",
2021
"no-console": "warn",
@@ -23,7 +24,6 @@
2324
"import/first": "off",
2425
"react/jsx-filename-extension": "off",
2526
"react/prefer-stateless-function": "off",
26-
"react/jsx-closing-bracket-location": [1, "props-aligned"],
2727
"react/require-default-props": "off"
2828
},
2929
"settings": {

packages/react-scripts/template/.template.dependencies.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"dependencies": {
33
"lodash": "4.17.4",
44
"prop-types": "15.5.10",
5-
"react-redux": "5.0.5",
6-
"react-router": "4.1.1",
7-
"react-router-dom": "4.1.1",
8-
"redux": "3.6.0",
5+
"react": "16.0.0",
6+
"react-redux": "5.0.6",
7+
"react-router": "4.2.0",
8+
"react-router-dom": "4.2.2",
9+
"redux": "3.7.2",
910
"redux-mock-store": "1.2.3",
1011
"redux-promise": "0.5.3",
1112
"redux-thunk": "2.2.0"

0 commit comments

Comments
 (0)