You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 29, 2023. It is now read-only.
Assuming you have Cypress installed, add this module as a dev dependency
71
+
Assuming you have Cypress installed, add this module as a dev dependency.
69
72
70
73
```shell
71
74
# using NPM
@@ -74,7 +77,10 @@ npm i -D cypress-grep
74
77
yarn add -D cypress-grep
75
78
```
76
79
80
+
**Note**: cypress-grep only works with Cypress version >= 10.
81
+
77
82
### Support file
83
+
78
84
**required:** load this module from the [support file](https://on.cypress.io/writing-and-organizing-tests#Support-file) or at the top of the spec file if not using the support file. You improve the registration function and then call it:
79
85
80
86
```js
@@ -89,7 +95,6 @@ import registerCypressGrep from 'cypress-grep'
89
95
registerCypressGrep()
90
96
```
91
97
92
-
93
98
### Config file
94
99
95
100
**optional:** load and register this module from the [config file](https://docs.cypress.io/guides/references/configuration#setupNodeEvents):
@@ -259,41 +264,59 @@ You can run tests that match one tag or another using spaces. Make sure to quote
259
264
--env grepTags='@slow @critical'
260
265
```
261
266
262
-
### Test suites
267
+
### Inverted tags
263
268
264
-
The tags are also applied to the "describe" blocks. In that case, the tests look up if any of their outer suites are enabled.
269
+
You can skip running the tests with specific tag using the invert option: prefix the tag with the character `-`.
265
270
266
-
```js
267
-
describe('block with config tag', { tags:'@smoke' }, () => {})
268
271
```
272
+
# do not run any tests with tag "@slow"
273
+
--env grepTags=-@slow
274
+
```
275
+
276
+
If you want to run all tests with tag `@slow` but without tag `@smoke`:
269
277
270
278
```
271
-
# run any tests in the blocks having "@smoke" tag
272
-
--env grepTags=@smoke
273
-
# skip any blocks with "@smoke" tag
274
-
--env grepTags=-@smoke
279
+
--env grepTags=@slow+-@smoke
275
280
```
276
281
277
-
See the [cypress/integration/describe-tags-spec.js](./cypress/integration/describe-tags-spec.js) file.
282
+
**Note:** Inverted tag filter is not compativle with the `grepFilterSpecs` option
278
283
279
-
**Note:** global function `describe` and `context` are aliases and both supported by this plugin.
284
+
### NOT tags
280
285
281
-
### Invert tag
286
+
You can skip running the tests with specific tag, even if they have a tag that should run, using the not option: prefix the tag with `--`.
282
287
283
-
You can skip running the tests with specific tag using the invert option: prefix the tag with the character `-`.
288
+
Note this is the same as appending `+-<tag to never run>` to each tag. May be useful with large number of tags.
289
+
290
+
If you want to run tests with tags `@slow` or `@regression` but without tag `@smoke`
284
291
285
292
```
286
-
# do not run any tests with tag "@slow"
287
-
--env grepTags=-@slow
293
+
--env grepTags='@slow @regression --@smoke'
288
294
```
289
295
290
-
If you want to run all tests with tag `@slow` but without tag `@smoke`:
**Note:** Inverted tag filter is not compativle with the `grepFilterSpecs` option
302
+
### Tags in test suites
303
+
304
+
The tags are also applied to the "describe" blocks. In that case, the tests look up if any of their outer suites are enabled.
305
+
306
+
```js
307
+
describe('block with config tag', { tags:'@smoke' }, () => {})
308
+
```
309
+
310
+
```
311
+
# run any tests in the blocks having "@smoke" tag
312
+
--env grepTags=@smoke
313
+
# skip any blocks with "@smoke" tag
314
+
--env grepTags=-@smoke
315
+
```
316
+
317
+
See the [cypress/integration/describe-tags-spec.js](./cypress/integration/describe-tags-spec.js) file.
318
+
319
+
**Note:** global function `describe` and `context` are aliases and both supported by this plugin.
297
320
298
321
### Grep untagged tests
299
322
@@ -363,7 +386,7 @@ cypress run --env grep="works 2",grepOmitFiltered=true
363
386
364
387
## Disable grep
365
388
366
-
If you specify the `grep` parameters inside `cypress.json` file, you can disable it from the command line
389
+
If you specify the `grep` parameters the [config file](https://docs.cypress.io/guides/references/configuration), you can disable it from the command line
367
390
368
391
```
369
392
$ npx cypress run --env grep=,grepTags=,burn=
@@ -562,6 +585,10 @@ The above scenario was confusing - did you want to find all tests with title con
562
585
--env grep=hello,grepTags=smoke
563
586
```
564
587
588
+
### from v2 to v3
589
+
590
+
Version >= 3 of cypress-grep _only_ supports Cypress >= 10.
591
+
565
592
## Videos & Blog Posts
566
593
567
594
Watch the video [intro to cypress-grep](https://www.youtube.com/watch?v=HS-Px-Sghd8) which shows how this repository tags tests, uses [cypress-grep](https://github.com/cypress-io/cypress-grep) plugin, and sets up the TypeScript intelligent code completion.
0 commit comments