@bahmutov/cy-grep 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-15.5.0-brightgreen)
1
+ # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-15.12.0-brightgreen)
2
2
 
3
3
  > Filter tests using substring or tag
4
4
 
@@ -771,7 +771,7 @@ Start Cypress with the environment variable `DEBUG=cy-grep`. You will see a few
771
771
  ```
772
772
  $ DEBUG=cy-grep npx cypress run --expose grep=works,grepFilterSpecs=true
773
773
  cy-grep: tests with "works" in their names
774
- cy-grep: filtering specs using "works" in the title
774
+ cy-grep: filtering specs using "works" in the test title
775
775
  cy-grep Cypress config env object: { grep: 'works', grepFilterSpecs: true }
776
776
  ...
777
777
  cy-grep found 1 spec files +5ms
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@bahmutov/cy-grep",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Filter Cypress tests using title or tags",
5
5
  "main": "src/support.js",
6
6
  "scripts": {
7
+ "dev": "cypress open --e2e -b electron",
7
8
  "cy:run": "cypress run --config specPattern='**/unit.js'",
8
9
  "cy:open": "cypress open --e2e -b electron --config specPattern='**/unit.js'",
9
10
  "cy:open:tags": "cypress open --e2e -b electron --config specPattern='cypress/e2e/test-tags/*.cy.js'",
10
11
  "badges": "npx -p dependency-version-badge update-badge cypress",
11
12
  "semantic-release": "semantic-release",
12
13
  "deps": "npm audit --report --omit dev",
13
- "stop-only": "stop-only --folder cypress/e2e"
14
+ "stop-only": "stop-only --folder cypress/e2e --exclude cypress/e2e/only/check-only.cy.js",
15
+ "open:check-only": "cypress open --e2e -b electron --config specPattern='cypress/e2e/only/check-only.cy.js' --expose grepFilterSpecs=true,grepOmitFiltered=true,grepTags=@one"
14
16
  },
15
17
  "dependencies": {
16
18
  "cypress-plugin-config": "^2.0.0",
@@ -20,12 +22,12 @@
20
22
  "globby": "^11.1.0"
21
23
  },
22
24
  "devDependencies": {
23
- "cypress": "15.11.0",
25
+ "cypress": "15.12.0",
24
26
  "cypress-each": "^1.11.0",
25
27
  "cypress-expect": "^3.1.0",
26
28
  "prettier": "^3.8.1",
27
29
  "semantic-release": "^25.0.3",
28
- "stop-only": "^3.3.1",
30
+ "stop-only": "^3.4.4",
29
31
  "typescript": "^5.9.3"
30
32
  },
31
33
  "peerDependencies": {
package/src/plugin.js CHANGED
@@ -80,6 +80,17 @@ function getGrepSettings(config) {
80
80
  console.log('cy-grep: all tags will be forced to start with @')
81
81
  }
82
82
 
83
+ // expose the collected config values
84
+ // so that the browser support code can use them
85
+ config.expose = config.expose || {}
86
+ config.expose.grep = grep
87
+ config.expose.grepTags = grepTags
88
+ config.expose.grepBurn = grepBurn
89
+ config.expose.grepUntagged = grepUntagged
90
+ config.expose.grepOmitFiltered = omitFiltered
91
+ config.expose.grepFilterSpecs = grepFilterSpecs
92
+ config.expose.grepPrefixAt = grepPrefixAt
93
+
83
94
  return { grep, grepTags, grepFilterSpecs, grepPrefixAt }
84
95
  }
85
96
 
@@ -131,7 +142,7 @@ function cypressGrepPlugin(config) {
131
142
  let greppedSpecs = []
132
143
 
133
144
  if (grep) {
134
- console.log('cy-grep: filtering specs using "%s" in the title', grep)
145
+ console.log('cy-grep: filtering specs using "%s" in the test title', grep)
135
146
  const parsedGrep = parseGrep(grep, undefined, grepPrefixAt)
136
147
 
137
148
  debug('parsed grep %o', parsedGrep)
package/src/support.js CHANGED
@@ -110,6 +110,16 @@ function registerCyGrep() {
110
110
  return
111
111
  }
112
112
 
113
+ // global state :(
114
+ // when using "it.only" it calls via internal Mocha functions our "it"
115
+ // BUT without passing test tags or test config -
116
+ // thus our "it" function thinks there are no effective tags to use
117
+ // against the current grep, so it skips the "it.only" test.
118
+ // we want the opposite: any "it.only" test should run
119
+ // thus we set this global flag from our "it.only" before
120
+ // Cypress/Mocha calls our "it" and we know to run the test without checking the tags
121
+ let insideItOnly = false
122
+
113
123
  it = function itGrep(name, options, callback) {
114
124
  if (typeof options === 'function') {
115
125
  // the test has format it('...', cb)
@@ -122,6 +132,11 @@ function registerCyGrep() {
122
132
  return _it(name, options)
123
133
  }
124
134
 
135
+ if (insideItOnly) {
136
+ insideItOnly = false
137
+ return _it(name, callback)
138
+ }
139
+
125
140
  let configTags = options && options.tags
126
141
  if (typeof configTags === 'string') {
127
142
  configTags = [configTags]
@@ -196,6 +211,7 @@ function registerCyGrep() {
196
211
  // omit the filtered tests completely
197
212
  // in order to be compatible with Mocha, create fake method and test object
198
213
  return {
214
+ markOnly: () => {},
199
215
  parent: {
200
216
  appendOnlyTest: () => {},
201
217
  },
@@ -273,7 +289,20 @@ function registerCyGrep() {
273
289
 
274
290
  // keep the ".skip", ".only" methods the same as before
275
291
  it.skip = _it.skip
276
- it.only = _it.only
292
+
293
+ const _itOnly = _it.only
294
+ it.only = function itGrep(name, options, callback) {
295
+ insideItOnly = true
296
+ if (typeof options === 'function') {
297
+ // the test has format it('...', cb)
298
+ callback = options
299
+ options = {}
300
+ }
301
+
302
+ debugger
303
+ return _itOnly(name, options, callback)
304
+ }
305
+
277
306
  // preserve "it.each" method if found
278
307
  if (typeof _it.each === 'function') {
279
308
  it.each = _it.each