Skip to content
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

Update docs to document --no-watch #6331

Merged
merged 6 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Another example of this is how `npm test` normally launches the watcher, but if

We prefer to add interactivity to the command line interface rather than add configuration flags. For example, `npm start` will attempt to run with port `3000` by default, but it may be busy. Many other tools just fail in this case and ask that you pass a different port, but Create React App will display a prompt asking if you’d like to run the app on the next available port.

Another example of interactivity is `npm test` watcher interface. Instead of asking people to pass command line flags for switching between test runner modes or search patterns, we print a hint with keys that you can press during the test session to instruct watcher what to do. Jest supports both flags and interactive CLI but Create React App prefers long-running sessions to keep user immersed in the flow over short-running sessions with different flags.
Another example of interactivity is `npm test` watcher interface. Instead of asking people to pass command line flags for switching between test runner modes or search patterns, we print a hint with keys that you can press during the test session to instruct watcher what to do. Jest supports both flags and interactive CLI but Create React App prefers long-running sessions to keep user immersed in the flow over short-running sessions with different flags (However, you can disable this by passing the flag `npm test -- --no-watch`).
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

### Breaking the Rules

Expand Down
4 changes: 3 additions & 1 deletion docusaurus/docs/available-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ The page will reload if you make edits. You will also see any lint errors in the

## `npm test`

Launches the test runner in the interactive watch mode. See the section about [running tests](running-tests.md) for more information.
Launches the test runner in the interactive watch mode<sup>\*</sup>. See the section about [running tests](running-tests.md) for more information.

> \*You can disable this behavior by passing the flag `--no-watch` if needed though, interactive mode is suggested.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

## `npm run build`

Expand Down
6 changes: 4 additions & 2 deletions docusaurus/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

When you’re ready to deploy to production, create a minified bundle with `npm run build`.

Expand Down Expand Up @@ -108,10 +108,12 @@ The page will automatically reload if you make changes to the code. You will see

### `npm test` or `yarn test`

Runs the test watcher in an interactive mode. By default, runs tests related to files changed since the last commit.
Runs the test watcher in an interactive mode<sup>\*</sup>. By default, runs tests related to files changed since the last commit.

[Read more about testing](https://facebook.github.io/create-react-app/docs/running-tests).

> \*You can disable this behavior by passing the flag `--no-watch` if needed though, interactive mode is suggested.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

### `npm run build` or `yarn build`

Builds the app for production to the `build` folder. It correctly bundles React in production mode and optimizes the build for the best performance.
Expand Down
10 changes: 5 additions & 5 deletions docusaurus/docs/running-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 the watch mode<sup>\*</sup>. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

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)

> \*You can disable this behavior by passing the flag `--no-watch` if needed though, interactive mode is suggested.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

## 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 don’t often commit the code that doesn’t pass the tests.
Expand Down Expand Up @@ -306,7 +308,7 @@ Example package.json:

## Continuous Integration

By default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`.
By default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI` or adding the flag `--no-watch`.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

When creating a build of your application with `npm run build` linter warnings are not checked by default. Like `npm test`, you can force the build to perform a linter warning check by setting the environment variable `CI`. If any warnings are encountered then the build fails.

Expand Down Expand Up @@ -372,9 +374,7 @@ CI=true npm test
CI=true npm run build
```

The test command will force Jest to run tests 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.
The test command will force Jest to run tests once instead of launching the watcher. If you prefer, you can also pass the flag `--no-watch` to disable the watcher too.
ricokahler marked this conversation as resolved.
Show resolved Hide resolved

The build command will check for linter warnings and fail if any are found.

Expand Down