Skip to content

Commit 9a70038

Browse files
authored
Preserve scripts/test.js after ejecting (#715)
Fixes #702
1 parent f54c9d8 commit 9a70038

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/react-scripts/scripts/eject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ prompt(
3939
path.join('config', 'jest', 'FileStub.js'),
4040
path.join('scripts', 'build.js'),
4141
path.join('scripts', 'start.js'),
42+
path.join('scripts', 'test.js'),
4243
path.join('scripts', 'utils', 'checkRequiredFiles.js'),
4344
path.join('scripts', 'utils', 'chrome.applescript'),
4445
path.join('scripts', 'utils', 'getClientEnvironment.js'),
@@ -98,7 +99,6 @@ prompt(
9899
delete appPackage.scripts['eject'];
99100
Object.keys(appPackage.scripts).forEach(function (key) {
100101
appPackage.scripts[key] = appPackage.scripts[key]
101-
.replace(/react-scripts test/g, 'jest --watch')
102102
.replace(/react-scripts (\w+)/g, 'node scripts/$1.js');
103103
});
104104

packages/react-scripts/scripts/test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @remove-on-eject-begin
12
/**
23
* Copyright (c) 2015-present, Facebook, Inc.
34
* All rights reserved.
@@ -6,6 +7,7 @@
67
* LICENSE file in the root directory of this source tree. An additional grant
78
* of patent rights can be found in the PATENTS file in the same directory.
89
*/
10+
// @remove-on-eject-end
911

1012
process.env.NODE_ENV = 'test';
1113
process.env.PUBLIC_URL = '';
@@ -16,7 +18,6 @@ process.env.PUBLIC_URL = '';
1618
// https://github.com/motdotla/dotenv
1719
require('dotenv').config({silent: true});
1820

19-
const createJestConfig = require('./utils/createJestConfig');
2021
const jest = require('jest');
2122
const path = require('path');
2223
const paths = require('../config/paths');
@@ -28,10 +29,14 @@ if (!process.env.CI) {
2829
argv.push('--watch');
2930
}
3031

32+
// @remove-on-eject-begin
33+
// This is not necessary after eject because we embed config into package.json.
34+
const createJestConfig = require('./utils/createJestConfig');
3135
argv.push('--config', JSON.stringify(createJestConfig(
3236
relativePath => path.resolve(__dirname, '..', relativePath),
3337
path.resolve(paths.appSrc, '..'),
3438
false
3539
)));
40+
// @remove-on-eject-end
3641

3742
jest.run(argv);

0 commit comments

Comments
 (0)