From bcf649f38e7115466d02d4f748d11f26e1716aec Mon Sep 17 00:00:00 2001 From: Bruno Farias Date: Wed, 28 Sep 2022 08:26:28 +0100 Subject: [PATCH] Update filter CLI option docs to match code implementation. Related to issue #13222 --- docs/CLI.md | 6 ++++-- website/versioned_docs/version-28.x/CLI.md | 6 ++++-- website/versioned_docs/version-29.0/CLI.md | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/CLI.md b/docs/CLI.md index dde424ed1acd..1fb5c14de929 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -202,11 +202,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch. ### `--filter=` -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, }; diff --git a/website/versioned_docs/version-28.x/CLI.md b/website/versioned_docs/version-28.x/CLI.md index 26c6928cac19..2b7952842847 100644 --- a/website/versioned_docs/version-28.x/CLI.md +++ b/website/versioned_docs/version-28.x/CLI.md @@ -208,11 +208,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch. ### `--filter=` -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, }; diff --git a/website/versioned_docs/version-29.0/CLI.md b/website/versioned_docs/version-29.0/CLI.md index 8f039a3ad281..cce1410b0dcc 100644 --- a/website/versioned_docs/version-29.0/CLI.md +++ b/website/versioned_docs/version-29.0/CLI.md @@ -202,11 +202,13 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch. ### `--filter=` -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, };