@bahmutov/cy-grep 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +21 -0
- package/package.json +2 -2
- package/src/plugin.js +4 -4
package/README.md
CHANGED
@@ -60,6 +60,7 @@ Watch the video [intro to cypress-grep plugin](https://www.youtube.com/watch?v=H
|
|
60
60
|
- [Disable grep](#disable-grep)
|
61
61
|
- [Burn (repeat) tests](#burn-repeat-tests)
|
62
62
|
- [Required tags](#required-tags)
|
63
|
+
- [Negative grep](#negative-grep)
|
63
64
|
- [TypeScript support](#typescript-support)
|
64
65
|
- [General advice](#general-advice)
|
65
66
|
- [DevTools console](#devtools-console)
|
@@ -486,6 +487,26 @@ If `grepFilterSpecs=true` and a spec has only required tags, and you are running
|
|
486
487
|
|
487
488
|
Read the blog post 📝 [Required Tags](https://glebbahmutov.com/blog/required-tags/).
|
488
489
|
|
490
|
+
## Negative grep
|
491
|
+
|
492
|
+
When grepping tests by title, the parent suite title is included. For example if this is the spec
|
493
|
+
|
494
|
+
```js
|
495
|
+
describe('users', () => {
|
496
|
+
it('works 1', () => {})
|
497
|
+
it('works 2', () => {})
|
498
|
+
it('works 3', () => {})
|
499
|
+
})
|
500
|
+
|
501
|
+
describe('projects', () => {
|
502
|
+
it('load 1', () => {})
|
503
|
+
it('load 2', () => {})
|
504
|
+
it('load 3', () => {})
|
505
|
+
})
|
506
|
+
```
|
507
|
+
|
508
|
+
You can run the tests inside the suite "projects" by using `--env grep=projects` and you can skip the tests in the suite `projects` by using `--env grep=-projects`.
|
509
|
+
|
489
510
|
## TypeScript support
|
490
511
|
|
491
512
|
Because the Cypress test config object type definition does not have the `tags` property we are using above, the TypeScript linter will show an error. Just add an ignore comment above the test:
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bahmutov/cy-grep",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.8.0",
|
4
4
|
"description": "Filter Cypress tests using title or tags",
|
5
5
|
"main": "src/support.js",
|
6
6
|
"scripts": {
|
@@ -22,7 +22,7 @@
|
|
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.
|
25
|
+
"semantic-release": "^20.1.3",
|
26
26
|
"typescript": "^4.7.4"
|
27
27
|
},
|
28
28
|
"peerDependencies": {
|
package/src/plugin.js
CHANGED
@@ -81,13 +81,13 @@ function cypressGrepPlugin(config) {
|
|
81
81
|
const text = fs.readFileSync(specFile, { encoding: 'utf8' })
|
82
82
|
|
83
83
|
try {
|
84
|
-
const
|
85
|
-
const
|
84
|
+
const result = getTestNames(text, true)
|
85
|
+
const testNames = result.fullTestNames
|
86
86
|
|
87
87
|
debug('spec file %s', specFile)
|
88
|
-
debug('
|
88
|
+
debug('full test names: %o', testNames)
|
89
89
|
|
90
|
-
return
|
90
|
+
return testNames.some((name) => {
|
91
91
|
const shouldRun = shouldTestRun(parsedGrep, name)
|
92
92
|
|
93
93
|
return shouldRun
|