@bahmutov/cy-grep 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +15 -3
- package/package.json +4 -4
- package/src/support.js +16 -7
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.
|
1
|
+
# @bahmutov/cy-grep ![cypress version](https://img.shields.io/badge/cypress-12.5.0-brightgreen)
|
2
2
|
|
3
3
|
> Filter tests using substring or tag
|
4
4
|
|
@@ -19,13 +19,25 @@ All other tests will be marked pending, see why in the [Cypress test statuses](h
|
|
19
19
|
|
20
20
|
If you have multiple spec files, all specs will be loaded, and every test will be filtered the same way, since the grep is run-time operation and cannot eliminate the spec files without loading them. If you want to run only specific tests, use the built-in [--spec](https://on.cypress.io/command-line#cypress-run-spec-lt-spec-gt) CLI argument.
|
21
21
|
|
22
|
-
|
22
|
+
## Training
|
23
23
|
|
24
|
-
|
24
|
+
Watch the video [intro to cypress-grep plugin](https://www.youtube.com/watch?v=HS-Px-Sghd8) and study my 🎓 Cypress course [Cypress Plugins](https://cypress.tips/courses/cypress-plugins):
|
25
|
+
|
26
|
+
- [Lesson k1: Set up the test grep plugin](https://cypress.tips/courses/cypress-plugins/lessons/k1)
|
27
|
+
- [Lesson k2: Filter the tests using test and suite tags](https://cypress.tips/courses/cypress-plugins/lessons/k2)
|
28
|
+
- [Lesson k3: Filter the specs without the tag we want to run](https://cypress.tips/courses/cypress-plugins/lessons/k3)
|
29
|
+
- [Lesson k4: Filter the tests to run using several tags](https://cypress.tips/courses/cypress-plugins/lessons/k4)
|
30
|
+
- [Lesson k5: Filter the tests to run using OR of several tags](https://cypress.tips/courses/cypress-plugins/lessons/k5)
|
31
|
+
- [Lesson k6: Repeat selected tests N times](https://cypress.tips/courses/cypress-plugins/lessons/k6)
|
32
|
+
- [Lesson k7: Pick the tests to run in the interactive mode](https://cypress.tips/courses/cypress-plugins/lessons/k7)
|
33
|
+
|
34
|
+
## Table of Contents
|
25
35
|
|
26
36
|
<!-- MarkdownTOC autolink="true" -->
|
27
37
|
|
28
38
|
- [@bahmutov/cy-grep ](#bahmutovcy-grep-)
|
39
|
+
- [Training](#training)
|
40
|
+
- [Table of Contents](#table-of-contents)
|
29
41
|
- [Install](#install)
|
30
42
|
- [Support file](#support-file)
|
31
43
|
- [Config file](#config-file)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bahmutov/cy-grep",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.3",
|
4
4
|
"description": "Filter Cypress tests using title or tags",
|
5
5
|
"main": "src/support.js",
|
6
6
|
"scripts": {
|
@@ -12,15 +12,15 @@
|
|
12
12
|
"dependencies": {
|
13
13
|
"cypress-plugin-config": "^1.2.0",
|
14
14
|
"debug": "^4.3.2",
|
15
|
-
"find-test-names": "1.
|
15
|
+
"find-test-names": "1.28.1",
|
16
16
|
"globby": "^11.0.4"
|
17
17
|
},
|
18
18
|
"devDependencies": {
|
19
|
-
"cypress": "12.
|
19
|
+
"cypress": "12.7.0",
|
20
20
|
"cypress-each": "^1.11.0",
|
21
21
|
"cypress-expect": "^3.1.0",
|
22
22
|
"prettier": "^2.8.1",
|
23
|
-
"semantic-release": "^20.1.
|
23
|
+
"semantic-release": "^20.1.1",
|
24
24
|
"typescript": "^4.7.4"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
package/src/support.js
CHANGED
@@ -110,7 +110,7 @@ function registerCyGrep() {
|
|
110
110
|
.flatMap((item) => item.requiredTags)
|
111
111
|
.concat(configRequiredTags)
|
112
112
|
.filter(Boolean)
|
113
|
-
|
113
|
+
debug({ nameToGrep, effectiveTestTags, requiredTestTags })
|
114
114
|
|
115
115
|
const shouldRun = shouldTestRun(
|
116
116
|
parsedGrep,
|
@@ -128,7 +128,7 @@ function registerCyGrep() {
|
|
128
128
|
shouldRun,
|
129
129
|
)
|
130
130
|
} else {
|
131
|
-
debug('should test "%s" run? %s', nameToGrep, shouldRun)
|
131
|
+
debug('should test without tags "%s" run? %s', nameToGrep, shouldRun)
|
132
132
|
}
|
133
133
|
|
134
134
|
if (shouldRun) {
|
@@ -183,20 +183,29 @@ function registerCyGrep() {
|
|
183
183
|
if (typeof configTags === 'string') {
|
184
184
|
configTags = [configTags]
|
185
185
|
}
|
186
|
+
let requiredTags = options && options.requiredTags
|
187
|
+
if (typeof requiredTags === 'string') {
|
188
|
+
requiredTags = [requiredTags]
|
189
|
+
}
|
186
190
|
|
187
191
|
if (!configTags || !configTags.length) {
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
+
if (!requiredTags || !requiredTags.length) {
|
193
|
+
// if the describe suite does not have explicit tags
|
194
|
+
// move on, since the tests inside can have their own tags
|
195
|
+
_describe(name, options, callback)
|
196
|
+
suiteStack.pop()
|
192
197
|
|
193
|
-
|
198
|
+
return
|
199
|
+
}
|
194
200
|
}
|
195
201
|
|
196
202
|
// when looking at the suite of the tests, I found
|
197
203
|
// that using the name is quickly becoming very confusing
|
198
204
|
// and thus we need to use the explicit tags
|
199
205
|
stackItem.tags = configTags
|
206
|
+
stackItem.requiredTags = requiredTags
|
207
|
+
debug('stack item', stackItem)
|
208
|
+
|
200
209
|
_describe(name, options, callback)
|
201
210
|
suiteStack.pop()
|
202
211
|
|