Skip to content

Commit a52b697

Browse files
authored
Enable watch implicitly unless on CI (#533)
Fixes #532
1 parent e48b617 commit a52b697

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"create-react-app": "node global-cli/index.js --scripts-version \"$PWD/`npm pack`\"",
1616
"e2e": "tasks/e2e.sh",
1717
"start": "node scripts/start.js --debug-template",
18-
"test": "node scripts/test.js --debug-template --watch --env=jsdom"
18+
"test": "node scripts/test.js --debug-template --env=jsdom"
1919
},
2020
"files": [
2121
"PATENTS",

Diff for: scripts/eject.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ prompt(
101101
delete appPackage.scripts['eject'];
102102
Object.keys(appPackage.scripts).forEach(function (key) {
103103
appPackage.scripts[key] = appPackage.scripts[key]
104-
.replace(/react-scripts test/g, 'jest')
104+
.replace(/react-scripts test/g, 'jest --watch')
105105
.replace(/react-scripts (\w+)/g, 'node scripts/$1.js');
106106
});
107107

Diff for: scripts/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function(appPath, appName, verbose, originalDirectory) {
2626
appPackage.scripts = {
2727
'start': 'react-scripts start',
2828
'build': 'react-scripts build',
29-
'test': 'react-scripts test --watch --env=jsdom',
29+
'test': 'react-scripts test --env=jsdom',
3030
'eject': 'react-scripts eject'
3131
};
3232

Diff for: scripts/test.js

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ if (debugTemplateIndex !== -1) {
2222
argv.splice(debugTemplateIndex, 1);
2323
}
2424

25+
// Watch unless on CI
26+
if (!process.env.CI) {
27+
argv.push('--watch');
28+
}
29+
2530
argv.push('--config', JSON.stringify(createJestConfig(
2631
relativePath => path.resolve(__dirname, '..', relativePath),
2732
path.resolve(paths.appSrc, '..')

Diff for: tasks/e2e.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ test -e build/static/css/*.css
6767
test -e build/static/media/*.svg
6868
test -e build/favicon.ico
6969

70-
# Run tests, overriding watch option to disable it
71-
npm test -- --watch=no
70+
# Run tests with CI flag
71+
CI=true npm test
7272
# Uncomment when snapshot testing is enabled by default:
7373
# test -e template/src/__snapshots__/App.test.js.snap
7474

@@ -101,8 +101,8 @@ test -e build/static/css/*.css
101101
test -e build/static/media/*.svg
102102
test -e build/favicon.ico
103103

104-
# Run tests, overriding watch option to disable it
105-
npm test -- --watch=no
104+
# Run tests with CI flag
105+
CI=true npm test
106106
# Uncomment when snapshot testing is enabled by default:
107107
# test -e src/__snapshots__/App.test.js.snap
108108

@@ -120,7 +120,8 @@ test -e build/static/css/*.css
120120
test -e build/static/media/*.svg
121121
test -e build/favicon.ico
122122

123-
# Run tests, overriding watch option to disable it
123+
# Run tests, overring the watch option to disable it
124+
# TODO: make CI flag respected after ejecting as well
124125
npm test -- --watch=no
125126
# Uncomment when snapshot testing is enabled by default:
126127
# test -e src/__snapshots__/App.test.js.snap

0 commit comments

Comments
 (0)