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

Commit 5516e5b

Browse files
authored
fix: use full grep tags to pre-filter specs (#99)
1 parent 0d09012 commit 5516e5b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ jobs:
224224
--env grepTags="high+smoke" \
225225
--expect-exactly expects/tags-and.json
226226
227+
# https://github.com/cypress-io/cypress-grep/issues/98
228+
- name: Tags OR specs with grepFilterSpecs=true 🧪
229+
run: |
230+
npx cypress-expect \
231+
--config testFiles="tags/*.spec.js" \
232+
--env grepTags="high regression",grepFilterSpecs=true \
233+
--expect-exactly expects/tags-or-filter.json
234+
227235
- name: Specify is an alias to it 🧪
228236
run: |
229237
npx cypress-expect \

expects/tags-or-filter.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"Test 1": "passing",
3+
"Test 2": "passing"
4+
}

src/plugin.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function cypressGrepPlugin(config) {
9090
}
9191
})
9292

93-
debug('found "%s" in %d specs', grep, specsWithText.length)
93+
debug('found grep "%s" in %d specs', grep, specsWithText.length)
9494
debug('%o', specsWithText)
9595

9696
config.testFiles = specsWithText
@@ -111,6 +111,9 @@ function cypressGrepPlugin(config) {
111111
debug('found %d spec files', specFiles.length)
112112
debug('%o', specFiles)
113113

114+
const parsedGrep = parseGrep(null, grepTags)
115+
debug('parsed grep tags %o', parsedGrep)
116+
114117
const specsWithText = specFiles.filter((specFile) => {
115118
const text = fs.readFileSync(
116119
path.join(config.integrationFolder, specFile),
@@ -122,8 +125,8 @@ function cypressGrepPlugin(config) {
122125
debug('test info: %o', testInfo.tests)
123126

124127
return testInfo.tests.some((info) => {
125-
// TODO: switch to using "shouldTestRun"
126-
return info.tags && info.tags.includes(grepTags)
128+
const shouldRun = shouldTestRun(parsedGrep, null, info.tags)
129+
return shouldRun
127130
})
128131
} catch (err) {
129132
console.error('Could not determine test names in file: %s', specFile)
@@ -132,7 +135,7 @@ function cypressGrepPlugin(config) {
132135
}
133136
})
134137

135-
debug('found "%s" in %d specs', grep, specsWithText.length)
138+
debug('found grep tags "%s" in %d specs', grepTags, specsWithText.length)
136139
debug('%o', specsWithText)
137140

138141
if (specsWithText.length) {

0 commit comments

Comments
 (0)