From 613f25b643988e59e5266223ce2279ab5a63d696 Mon Sep 17 00:00:00 2001 From: Gramsco <45275394+gramsco@users.noreply.github.com> Date: Tue, 3 May 2022 15:30:51 +0200 Subject: [PATCH] Update documentation (see #12260) This PR specifies how to use the filtering function CLI option. --- website/versioned_docs/version-28.0/CLI.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/website/versioned_docs/version-28.0/CLI.md b/website/versioned_docs/version-28.0/CLI.md index 694de03a17cb..4ea73b5a6562 100644 --- a/website/versioned_docs/version-28.0/CLI.md +++ b/website/versioned_docs/version-28.0/CLI.md @@ -204,7 +204,18 @@ 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 method receives a list of tests which can be manipulated to exclude tests from running. Especially useful when used in conjunction with a testing infrastructure to filter known broken. +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. + +```javascript +// my-filter.js +module.exports = (testPaths) => { + const allowedPaths = testPaths.filter(filteringFunction) // ["path1.spec.js", "path2.spec.js", etc] + return { + filtered : allowedPaths, + } +} +``` + ### `--findRelatedTests `