@bahmutov/cy-grep 1.9.11 → 1.9.14

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.
Files changed (3) hide show
  1. package/README.md +10 -1
  2. package/package.json +3 -3
  3. package/src/plugin.js +17 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.13.0-brightgreen)
1
+ # @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.14.0-brightgreen)
2
2
 
3
3
  > Filter tests using substring or tag
4
4
 
@@ -63,6 +63,7 @@ Watch the video [intro to cypress-grep plugin](https://www.youtube.com/watch?v=H
63
63
  - [Negative grep](#negative-grep)
64
64
  - [TypeScript support](#typescript-support)
65
65
  - [grepPrefixAt](#grepprefixat)
66
+ - [grepSpec](#grepspec)
66
67
  - [General advice](#general-advice)
67
68
  - [DevTools console](#devtools-console)
68
69
  - [grepFailed](#grepfailed)
@@ -552,6 +553,14 @@ Using test tags that start with `@` is so common, you can enforce it using the e
552
553
  --env grepTags=tag1
553
554
  ```
554
555
 
556
+ ## grepSpec
557
+
558
+ If the user selected spec(s) to run, then it might conflict with `grepFilterSpecs=true` that filters the specs. There is no way to "know" if the user used `--spec <...>` option when the plugin runs, see issues [33](https://github.com/bahmutov/cy-grep/issues/33) and [26032](https://github.com/cypress-io/cypress/issues/26032). Thus if you use `--spec pattern`, you need to pass it to the plugin via `CYPRESS_grepSpec=pattern` or `--env grepSpec=pattern` option.
559
+
560
+ ```
561
+ cypress run --spec a.cy.js --env grepTags=...,grepSpec=a.cy.js
562
+ ```
563
+
555
564
  ## General advice
556
565
 
557
566
  - keep it simple.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmutov/cy-grep",
3
- "version": "1.9.11",
3
+ "version": "1.9.14",
4
4
  "description": "Filter Cypress tests using title or tags",
5
5
  "main": "src/support.js",
6
6
  "scripts": {
@@ -18,11 +18,11 @@
18
18
  "find-test-names": "1.28.11"
19
19
  },
20
20
  "devDependencies": {
21
- "cypress": "12.13.0",
21
+ "cypress": "12.14.0",
22
22
  "cypress-each": "^1.11.0",
23
23
  "cypress-expect": "^3.1.0",
24
24
  "prettier": "^2.8.1",
25
- "semantic-release": "^20.1.3",
25
+ "semantic-release": "^21.0.3",
26
26
  "stop-only": "^3.3.1",
27
27
  "typescript": "^4.7.4"
28
28
  },
package/src/plugin.js CHANGED
@@ -7,6 +7,9 @@ const fs = require('fs')
7
7
  const path = require('path')
8
8
  const { version } = require('../package.json')
9
9
  const { parseGrep, shouldTestRun, getMentionedTags } = require('./utils')
10
+ const minimatch = require('minimatch')
11
+
12
+ const MINIMATCH_OPTIONS = { dot: true, matchBase: true }
10
13
 
11
14
  const isCypressV9 = (config) => !('specPattern' in config)
12
15
 
@@ -73,10 +76,22 @@ function cypressGrepPlugin(config) {
73
76
  getGrepSettings(config)
74
77
 
75
78
  if (grepFilterSpecs) {
76
- const specFiles = getSpecs(config)
79
+ let specFiles = getSpecs(config)
77
80
 
78
- debug('found %d spec files', specFiles.length)
81
+ debug('found %d spec file(s)', specFiles.length)
79
82
  debug('%o', specFiles)
83
+ const specPattern = config.env.grepSpec || config.env.grepSpecs
84
+ if (specPattern) {
85
+ debug('custom spec pattern: %s', specPattern)
86
+ // https://github.com/bahmutov/cy-grep/issues/33
87
+ // the user set a custom "--spec <...>" parameter to select specs to run
88
+ // so we need to pre-filter all found specFiles
89
+ specFiles = specFiles.filter((specFilename) =>
90
+ minimatch(specFilename, specPattern, MINIMATCH_OPTIONS),
91
+ )
92
+ debug('pre-filtered specs %d %o', specFiles.length, specFiles)
93
+ }
94
+
80
95
  let greppedSpecs = []
81
96
 
82
97
  if (grep) {