@bahmutov/cy-grep 1.7.3 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
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.7.3",
3
+ "version": "1.8.0",
4
4
  "description": "Filter Cypress tests using title or tags",
5
5
  "main": "src/support.js",
6
6
  "scripts": {
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 names = getTestNames(text, false)
85
- const testAndSuiteNames = names.suiteNames.concat(names.testNames)
84
+ const result = getTestNames(text, true)
85
+ const testNames = result.fullTestNames
86
86
 
87
87
  debug('spec file %s', specFile)
88
- debug('suite and test names: %o', testAndSuiteNames)
88
+ debug('full test names: %o', testNames)
89
89
 
90
- return testAndSuiteNames.some((name) => {
90
+ return testNames.some((name) => {
91
91
  const shouldRun = shouldTestRun(parsedGrep, name)
92
92
 
93
93
  return shouldRun