@@ -4,6 +4,7 @@ const { getTestNames } = require('find-test-names')
4
4
const fs = require ( 'fs' )
5
5
const path = require ( 'path' )
6
6
const { version } = require ( '../package.json' )
7
+ const { parseGrep, shouldTestRun } = require ( './utils' )
7
8
8
9
/**
9
10
* Prints the cypress-grep environment values if any.
@@ -62,6 +63,9 @@ function cypressGrepPlugin(config) {
62
63
debug ( 'found %d spec files' , specFiles . length )
63
64
debug ( '%o' , specFiles )
64
65
66
+ const parsedGrep = parseGrep ( grep )
67
+ debug ( 'parsed grep %o' , parsedGrep )
68
+
65
69
const specsWithText = specFiles . filter ( ( specFile ) => {
66
70
const text = fs . readFileSync (
67
71
path . join ( config . integrationFolder , specFile ) ,
@@ -73,7 +77,10 @@ function cypressGrepPlugin(config) {
73
77
debug ( 'spec file %s' , specFile )
74
78
debug ( 'suite and test names: %o' , testAndSuiteNames )
75
79
76
- return testAndSuiteNames . some ( ( name ) => name . includes ( grep ) )
80
+ return testAndSuiteNames . some ( ( name ) => {
81
+ const shouldRun = shouldTestRun ( parsedGrep , name )
82
+ return shouldRun
83
+ } )
77
84
} catch ( err ) {
78
85
console . error ( 'Could not determine test names in file: %s' , specFile )
79
86
console . error ( 'Will run it to let the grep filter the tests' )
@@ -113,6 +120,7 @@ function cypressGrepPlugin(config) {
113
120
debug ( 'test info: %o' , testInfo . tests )
114
121
115
122
return testInfo . tests . some ( ( info ) => {
123
+ // TODO: switch to using "shouldTestRun"
116
124
return info . tags && info . tags . includes ( grepTags )
117
125
} )
118
126
} catch ( err ) {
0 commit comments