-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Don't force "--watch" into Jest #784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is there a reason you don’t want to set |
Yes, it feels like a hack to set CI=true for a git hook that has nothing to do with CI.
IF we have to use environment variables for this, maybe we can go for a more intuitive name like "WATCH" or "TEST_WATCH" or "WATCH_TESTS".
I have watched your talk about how Redux and hot reloading can improve developer productivity by shortening the code-run-debug loop and I totally understand why it's a good idea to keep the test runner watch the files. But the test command has a bit of an odd behaviour if you've worked with anything like Mocha or even Jest. The test runners by default run the test once and if someone wants the watch behavior, s/he opts-in. I feel that CRA is targeted at newbies and tries to help them by using best practices, but the CI=true solution seems a bit hacky and hard to grok. |
I understand your concerns and |
Going to close this for reasons above. Happy to revisit in a few months if you’d like. |
Sorry for being so persistent. I made a PR to demonstrate one possible solution. Another (better IMHO) solution is not to do anything based on the environment variables and let the "test" script in Another solution is to keep the I'll be happy to help with another PR whatever makes more sense (and update the docs). |
From your PR:
I understand your arguments well. I have considered each of these options (including leaving |
Simple hack is to prevent react-scripts test --watchAll=false This works because the code detects presence of if (
!process.env.CI &&
argv.indexOf('--coverage') === -1 &&
argv.indexOf('--watchAll') === -1
) {
argv.push('--watch');
} |
Having a problem making your wonderful workaround work nicely as CRA 1.1.4 is insisting on using a previous copy 20.0.4 of Jest, which doesn't (?) support |
Just a heads up, you can also use
|
Hi @gaearon To update snapshots without the --watch, I can do `"test:updateSnapshots": "CI=true npm run test -- --updateSnapshot",`` The I'll be fine with it, just reporting the issue |
Another option was to use `CI=true`, refs: facebook/create-react-app#784
I'm a bit confused by the syntax Why doesn't this operate the same as |
@ScottMcCormack, that tells |
If you are reporting a bug, please fill in below. Otherwise feel to remove this template entirely.
Description
I want the tests to terminate after running once. But there doesn't seem to be any way to disable this behavior except setting the
CI
environment variable like:"test": "CD=true react-scripts test --env=jsdom",
in package.json. I traced the source of this behavior to these lines in test.jsI understand that watching can be good when in the development cycle but when I want to run the tests in a pipeline or some script or git push hooks, I want to escape this mechanism.
Expected behavior
One of these
npm test
run only once and then make another one callednpm run test:watch
that watches.npm run test:once
Actual behavior
Tell us what actually happens.
Environment
react-scripts@0.4.1
node@6.5.0
npm@3.10.3
I can make a PR if this behavior is confirmed.
The text was updated successfully, but these errors were encountered: