Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
fix: if filtering by grep eliminates all specs, do not filter them
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 29, 2021
1 parent f913e48 commit 44ef6a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -205,6 +205,8 @@ Note: this requires installing this plugin in your project's plugin file, see th

Note 2: the `grepFilterSpecs` option is only compatible with the positive `grep` and `grepTags` options, not with the negative "!..." filter.

Note 3: if there are no files remaining after filtering, the plugin prints a warning and leaves all files unchanged to avoid the test runner erroring with "No specs found".

**Tip:** you can set this environment variable in the `cypress.json` file to enable it by default and skip using the environment variable:

```json
Expand Down
8 changes: 7 additions & 1 deletion src/plugin.js
Expand Up @@ -117,7 +117,13 @@ function cypressGrepPlugin(config) {
debug('found "%s" in %d specs', grep, specsWithText.length)
debug('%o', specsWithText)

config.testFiles = specsWithText
if (specsWithText.length) {
config.testFiles = specsWithText
} else {
// hmm, we filtered out all specs, probably something is wrong
console.warn('Grep "%s" has eliminated all specs', grep)
console.warn('Will leave all specs to run to filter at run-time')
}
}
}

Expand Down

0 comments on commit 44ef6a5

Please sign in to comment.