Skip to content

Commit c0b0d7b

Browse files
committed
Move ignoredByWatcher to watchMode.ignoreChanges
1 parent 4f52a9f commit c0b0d7b

File tree

11 files changed

+31
-11
lines changed

11 files changed

+31
-11
lines changed

docs/06-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con
4343
## Options
4444

4545
- `files`: an array of glob patterns to select test files. Files with an underscore prefix are ignored. By default only selects files with `cjs`, `mjs` & `js` extensions, even if the pattern matches other files. Specify `extensions` to allow other file extensions
46-
- `ignoredByWatcher`: an array of glob patterns to match files that, even if changed, are ignored by the watcher. See the [watch mode recipe for details](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md)
46+
- `watchMode`: See the [watch mode recipe for details](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md)
4747
- `match`: not typically useful in the `package.json` configuration, but equivalent to [specifying `--match` on the CLI](./05-command-line.md#running-tests-with-matching-titles)
4848
- `cache`: defaults to `true` to cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead
4949
- `concurrency`: max number of test files running at the same time (default: CPU cores)

docs/recipes/watch-mode.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,17 @@ Otherwise, AVA 6 uses `fs.watch()`. Support for `recursive` mode is required. No
3737

3838
By default AVA watches for changes to all files, except for those with a `.snap.md` extension, `ava.config.*` and files in [certain directories](https://github.com/novemberborn/ignore-by-default/blob/master/index.js) as provided by the [`ignore-by-default`] package.
3939

40-
You can configure additional patterns for files to ignore in the [`ava` section of your `package.json`, or `ava.config.*` file][config], using the `ignoredByWatcher` key.
40+
With AVA 5, you can configure additional patterns for files to ignore in the [`ava` section of your `package.json`, or `ava.config.*` file][config], using the `ignoredByWatcher` key.
41+
42+
With AVA 6, place these patterns within the `watchMode` object:
43+
44+
```js
45+
export default {
46+
watchMode: {
47+
ignoreChanges: ['coverage'],
48+
},
49+
};
50+
```
4151

4252
If your tests write to disk they may trigger the watcher to rerun your tests. Configuring additional ignore patterns helps avoid this.
4353

lib/cli.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ export default async function loadCli() { // eslint-disable-line complexity
327327
exit('’watch’ must not be configured, use the --watch CLI flag instead.');
328328
}
329329

330+
if (Object.hasOwn(conf, 'ignoredByWatcher')) {
331+
exit('’ignoredByWatcher’ has moved to ’watchMode.ignoreChanges’.');
332+
}
333+
330334
if (!combined.tap && Object.keys(experiments).length > 0) {
331335
console.log(chalk.magenta(` ${figures.warning} Experiments are enabled. These are unsupported and may change or be removed at any time.`));
332336
}
@@ -380,7 +384,7 @@ export default async function loadCli() { // eslint-disable-line complexity
380384

381385
let globs;
382386
try {
383-
globs = normalizeGlobs({files: conf.files, ignoredByWatcher: conf.ignoredByWatcher, extensions, providers});
387+
globs = normalizeGlobs({files: conf.files, ignoredByWatcher: conf.watchMode?.ignoreChanges, extensions, providers});
384388
} catch (error) {
385389
exit(error.message);
386390
}

lib/globs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function normalizeGlobs({extensions, files: filePatterns, ignoredByWatche
3939
}
4040

4141
if (ignoredByWatcherPatterns !== undefined && (!Array.isArray(ignoredByWatcherPatterns) || ignoredByWatcherPatterns.length === 0)) {
42-
throw new Error('The ’ignoredByWatcher’ configuration must be an array containing glob patterns.');
42+
throw new Error('The ’watchMode.ignoreChanges’ configuration must be an array containing glob patterns.');
4343
}
4444

4545
const extensionPattern = buildExtensionPattern(extensions);

test-tap/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function apiCreator(options = {}) {
1717
options.concurrency = 2;
1818
options.extensions = options.extensions || ['cjs'];
1919
options.experiments = {};
20-
options.globs = normalizeGlobs({files: options.files, ignoredByWatcher: options.ignoredByWatcher, extensions: options.extensions, providers: []});
20+
options.globs = normalizeGlobs({files: options.files, ignoredByWatcher: options.watchMode?.ignoreChanges, extensions: options.extensions, providers: []});
2121
const instance = new Api(options);
2222

2323
return instance;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"type": "module",
33
"ava": {
4-
"ignoredByWatcher": []
4+
"watchMode": {
5+
"ignoreChanges": []
6+
}
57
}
68
}

test/globs/snapshots/test.js.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Generated by [AVA](https://avajs.dev).
1010
1111
'The ’files’ configuration must be an array containing glob patterns.'
1212

13-
## errors if top-level ignoredByWatcher is an empty array
13+
## errors if watchMode.ignoreChanges is an empty array
1414

1515
> fails with message
1616
17-
'The ’ignoredByWatcher’ configuration must be an array containing glob patterns.'
17+
'The ’watchMode.ignoreChanges’ configuration must be an array containing glob patterns.'
1818

1919
## files can be filtered by directory
2020

test/globs/snapshots/test.js.snap

4 Bytes
Binary file not shown.

test/globs/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('errors if top-level files is an empty array', async t => {
1212
t.snapshot(cleanOutput(result.stderr), 'fails with message');
1313
});
1414

15-
test('errors if top-level ignoredByWatcher is an empty array', async t => {
15+
test('errors if watchMode.ignoreChanges is an empty array', async t => {
1616
const options = {
1717
cwd: cwd('ignored-by-watcher'),
1818
};
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export default {
2-
ignoredByWatcher: ['ignored-by-watcher.js'],
2+
watchMode: {
3+
ignoreChanges: ['ignored-by-watcher.js'],
4+
},
35
};
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export default {
2-
ignoredByWatcher: ['ignored-by-watcher.js'],
2+
watchMode: {
3+
ignoreChanges: ['ignored-by-watcher.js'],
4+
},
35
};

0 commit comments

Comments
 (0)