Skip to content

Commit

Permalink
Remove selection of AVA 5 watcher
Browse files Browse the repository at this point in the history
When I first retained the AVA 5 logic, it was under the assumption AVA 6 would be released in the summer with another breaking release later in the year. It's now autumn, Node.js 16 is end of life, and for now it's just not worth having this logic around.

Depending on how well the watcher works I'm not opposed to having it as an experimental "select your watch mode" feature though.
  • Loading branch information
novemberborn committed Nov 6, 2023
1 parent d250c45 commit d173389
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 725 deletions.
15 changes: 1 addition & 14 deletions docs/recipes/watch-mode.md
Expand Up @@ -4,17 +4,6 @@ Translations: [Fran莽ais](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs

AVA comes with an intelligent watch mode. It watches for files to change and runs just those tests that are affected.

AVA 6 is introducing a new watch mode that relies on recurse file watching in Node.js. To use the old watch mode, set the implementation to `ava5+chokidar` and install [`chokidar`] alongside AVA:

`ava.config.mjs`:
```js
export default {
watchMode: {
implementation: 'ava5+chokidar',
},
}
```

## Running tests with watch mode enabled

You can enable watch mode using the `--watch` or `-w` flags:
Expand All @@ -29,8 +18,6 @@ Please note that integrated debugging and the TAP reporter are unavailable when

AVA 5 uses [`chokidar`] as the file watcher. Note that even if you see warnings about optional dependencies failing during install, it will still work fine. Please refer to the *[Install Troubleshooting]* section of `chokidar` documentation for how to resolve the installation problems with chokidar.

The same applies with AVA 6 when using the `ava5+chokidar` watcher. However you'll need to install `chokidar` separately.

Otherwise, AVA 6 uses `fs.watch()`. Support for `recursive` mode is required. Note that this has only become available on Linux since Node.js 20. [Other caveats apply](https://nodejs.org/api/fs.html#caveats), for example this won't work well on network filesystems and Docker host mounts.

## Ignoring changes
Expand All @@ -55,7 +42,7 @@ If your tests write to disk they may trigger the watcher to rerun your tests. Co

AVA tracks which source files your test files depend on. If you change such a dependency only the test file that depends on it will be rerun. AVA will rerun all tests if it cannot determine which test file depends on the changed source file.

AVA 5 (and the `ava5+chokidar` watcher in AVA 6) spies on `require()` calls to track dependencies. Custom extensions and transpilers are supported, provided you [added them in your `package.json` or `ava.config.*` file][config], and not from inside your test file.
AVA 5 spies on `require()` calls to track dependencies. Custom extensions and transpilers are supported, provided you [added them in your `package.json` or `ava.config.*` file][config], and not from inside your test file.

With AVA 6, dependency tracking works for `require()` and `import` syntax, as supported by [@vercel/nft](https://github.com/vercel/nft). `import()` is supported but dynamic paths such as `import(myVariable)` are not.

Expand Down

0 comments on commit d173389

Please sign in to comment.