Allow `npm test` to not run in watch mode for better cross-platform / tooling CI.
See original GitHub issueI’ve been using create-react-app in conjunction with lerna repos and for the most part its been an awesome experience. The one issue I’ve been seeing is when trying to issue lerna run test
commands to test all packages that have a “test” script. Since create-react-app defaults to entering watch mode on test, it hangs.
After some digging it looks like I might be able to set a CI
environment variable to disable the watch mode, however this does not work well due to the nuances of setting environment variables cross platform.
Something as simple as changing the default from
"test": "react-scripts test --env=jsdom",
to
"test": "react-scripts test --env=jsdom --watch",
would allow me to simply turn it off. Conversely adding an optional --no-watch
or --single-run
flag would solve the problem.
I’m happy to submit a PR, but wanted to get some feedback first on the internal direction regarding whether this has been considered in the past, and the reasoning around the current implementation. I get that its a nice experience for the casual user, but at the cost of CI and incompatibility with lerna there should be some sort of escape hatch (short of eject).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:22
- Comments:12 (4 by maintainers)
@cchamberlain I’ve just changed my
package.json
to:which works great
You can set them in cross-platform way:
then use
I think you might have misunderstood. In most CIs you don’t need to set this variable because it is already set by CI environments. Travis, Circle, and probably others already do this.
I hope this helps!