Add --no-watch test flag to docs (#6331)

This commit is contained in:
Rico Kahler
2019-02-04 02:21:05 -05:00
committed by Brody McKee
parent a78be99b5e
commit dea19fdb30
3 changed files with 8 additions and 5 deletions

View File

@@ -54,7 +54,8 @@ Use the following [`launch.json`](https://code.visualstudio.com/docs/editor/debu
"args": [
"test",
"--runInBand",
"--no-cache"
"--no-cache",
"--no-watch"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",

View File

@@ -18,7 +18,7 @@ npm start
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_
Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
When youre ready to deploy to production, create a minified bundle with `npm run build`.

View File

@@ -29,12 +29,14 @@ We recommend to put the test files (or `__tests__` folders) next to the code the
## Command Line Interface
When you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code.
When you run `npm test`, Jest will launch in watch mode<sup>\*</sup>. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code.
The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run:
![Jest watch mode](https://jestjs.io/img/blog/15-watch.gif)
> \*Although we recommend running your tests in watch mode during development, you can disable this behavior by passing in the `--no-watch` flag. In most CI environments, this is handled for you (see [On CI servers](#on-ci-servers)).
## Version Control Integration
By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you dont often commit the code that doesnt pass the tests.
@@ -372,9 +374,9 @@ CI=true npm test
CI=true npm run build
```
The test command will force Jest to run tests once instead of launching the watcher.
The test command will force Jest to run in CI-mode, and tests will only run once instead of launching the watcher.
> If you find yourself doing this often in development, please [file an issue](https://github.com/facebook/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows.
For non-CI environments, you can simply pass the `--no-watch` flag to disable test-watching.
The build command will check for linter warnings and fail if any are found.