Skip to content

Commit

Permalink
Update filter CLI option docs to match code implementation. Related t…
Browse files Browse the repository at this point in the history
…o issue jestjs#13222
  • Loading branch information
brunocabral88 committed Sep 28, 2022
1 parent 35e8b6a commit 09d0ef5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.

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

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.
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.

```js title="my-filter.js"
module.exports = testPaths => {
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
const allowedPaths = testPaths.filter(filteringFunction)
.map(test => ({ test })); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]

return {
filtered: allowedPaths,
};
Expand Down
6 changes: 4 additions & 2 deletions website/versioned_docs/version-28.x/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.

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

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.
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.

```js title="my-filter.js"
module.exports = testPaths => {
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
const allowedPaths = testPaths.filter(filteringFunction)
.map(test => ({ test })); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]

return {
filtered: allowedPaths,
};
Expand Down
6 changes: 4 additions & 2 deletions website/versioned_docs/version-29.0/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.

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

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.
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.

```js title="my-filter.js"
module.exports = testPaths => {
const allowedPaths = testPaths.filter(filteringFunction); // ["path1.spec.js", "path2.spec.js", etc]
const allowedPaths = testPaths.filter(filteringFunction)
.map(test => ({ test })); // [{ test: "path1.spec.js" }, { test: "path2.spec.js" }, etc]

return {
filtered: allowedPaths,
};
Expand Down

0 comments on commit 09d0ef5

Please sign in to comment.