Skip to content

Commit aa46c76

Browse files
committed
docs: add watch mode tips and best practices section
1 parent 7cf3b8d commit aa46c76

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/CLI.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,17 @@ Whether to use [worker threads](https://nodejs.org/dist/latest/docs/api/worker_t
565565
This is **experimental feature**. See the [`workerThreads` configuration option](Configuration.md#workerthreads) for more details.
566566

567567
:::
568+
569+
## Watch Mode Tips
570+
571+
When using Jest in watch mode (`--watch` or `--watchAll`), here are some best practices to maximize productivity:
572+
573+
- **Use `--testNamePattern` (`-t`)** in combination with `--watch` to focus on specific tests while developing.
574+
- **Press `o` in watch mode** to only run tests related to changed files instead of all tests.
575+
- **Press `f` in watch mode** to run only the tests that failed in the previous run.
576+
- **Press `p` in watch mode** to filter tests by filename pattern interactively.
577+
- **Set `--maxWorkers`** if watch mode is consuming too much memory or CPU on your machine.
578+
- **Use `--bail`** (`-x`) to stop after the first test failure, useful for TDD workflows.
579+
- **Clear cache** with `jest --clearCache` if you encounter stale cache issues during long watch sessions.
580+
581+
For more details, see the [Configuration](Configuration.md) page and run `jest --help` for all available options.

0 commit comments

Comments
 (0)