Skip to content

Commit e21c5ab

Browse files
docs: update --filter to match code implementation (#13329)
1 parent fd9cd90 commit e21c5ab

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

docs/CLI.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,14 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.
202202

203203
### `--filter=<file>`
204204

205-
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with the "filtered" property. Especially useful when used in conjunction with a testing infrastructure to filter known broken, e.g.
205+
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with shape `{ filtered: Array<{ test: string }> }`. Especially useful when used in conjunction with a testing infrastructure to filter known broken tests, e.g.
206206

207207
```js title="my-filter.js"
208208
module.exports = testPaths => {
209-
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
209+
const allowedPaths = testPaths
210+
.filter(filteringFunction)
211+
.map(test => ({test})); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]
212+
210213
return {
211214
filtered: allowedPaths,
212215
};

website/versioned_docs/version-28.x/CLI.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,14 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.
208208

209209
### `--filter=<file>`
210210

211-
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with the "filtered" property. Especially useful when used in conjunction with a testing infrastructure to filter known broken, e.g.
211+
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with shape `{ filtered: Array<{ test: string }> }`. Especially useful when used in conjunction with a testing infrastructure to filter known broken tests, e.g.
212212

213213
```js title="my-filter.js"
214214
module.exports = testPaths => {
215-
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
215+
const allowedPaths = testPaths
216+
.filter(filteringFunction)
217+
.map(test => ({test})); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]
218+
216219
return {
217220
filtered: allowedPaths,
218221
};

website/versioned_docs/version-29.0/CLI.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,14 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.
202202

203203
### `--filter=<file>`
204204

205-
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with the "filtered" property. Especially useful when used in conjunction with a testing infrastructure to filter known broken, e.g.
205+
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with shape `{ filtered: Array<{ test: string }> }`. Especially useful when used in conjunction with a testing infrastructure to filter known broken tests, e.g.
206206

207207
```js title="my-filter.js"
208208
module.exports = testPaths => {
209-
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
209+
const allowedPaths = testPaths
210+
.filter(filteringFunction)
211+
.map(test => ({test})); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]
212+
210213
return {
211214
filtered: allowedPaths,
212215
};

website/versioned_docs/version-29.1/CLI.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,14 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.
202202

203203
### `--filter=<file>`
204204

205-
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with the "filtered" property. Especially useful when used in conjunction with a testing infrastructure to filter known broken, e.g.
205+
Path to a module exporting a filtering function. This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running by returning an object with shape `{ filtered: Array<{ test: string }> }`. Especially useful when used in conjunction with a testing infrastructure to filter known broken tests, e.g.
206206

207207
```js title="my-filter.js"
208208
module.exports = testPaths => {
209-
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
209+
const allowedPaths = testPaths
210+
.filter(filteringFunction)
211+
.map(test => ({test})); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]
212+
210213
return {
211214
filtered: allowedPaths,
212215
};

0 commit comments

Comments
 (0)