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

Commit 44ef6a5

Browse files
committed
fix: if filtering by grep eliminates all specs, do not filter them
1 parent f913e48 commit 44ef6a5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ Note: this requires installing this plugin in your project's plugin file, see th
205205

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

208+
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".
209+
208210
**Tip:** you can set this environment variable in the `cypress.json` file to enable it by default and skip using the environment variable:
209211

210212
```json

src/plugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ function cypressGrepPlugin(config) {
117117
debug('found "%s" in %d specs', grep, specsWithText.length)
118118
debug('%o', specsWithText)
119119

120-
config.testFiles = specsWithText
120+
if (specsWithText.length) {
121+
config.testFiles = specsWithText
122+
} else {
123+
// hmm, we filtered out all specs, probably something is wrong
124+
console.warn('Grep "%s" has eliminated all specs', grep)
125+
console.warn('Will leave all specs to run to filter at run-time')
126+
}
121127
}
122128
}
123129

0 commit comments

Comments
 (0)