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.
Copy file name to clipboardExpand all lines: README.md
+11-32Lines changed: 11 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ npm i -D cypress-grep
34
34
yarn add -D cypress-grep
35
35
```
36
36
37
+
### Support file
37
38
**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:
38
39
39
40
```js
@@ -48,47 +49,25 @@ import registerCypressGrep from 'cypress-grep'
48
49
registerCypressGrep()
49
50
```
50
51
51
-
### Plugin file
52
52
53
-
**optional:** load and register this module from the [plugin file](https://on.cypress.io/writing-and-organizing-tests#Plugins-file)
53
+
### Config file
54
54
55
-
```js
56
-
// cypress/plugins/index.js
57
-
module.exports= (on, config) => {
58
-
// optional: register cypress-grep plugin code
59
-
// https://github.com/cypress-io/cypress-grep
60
-
require('cypress-grep/src/plugin')(config)
61
-
// make sure to return the config object
62
-
// as it might have been modified by the plugin
63
-
return config
64
-
}
65
-
```
66
-
67
-
By loading this module from the plugin file, it allows the `cypress-grep` to print a little message on load, for example
68
-
69
-
```shell
70
-
$ npx cypress run --env grep=hello
71
-
cypress-grep: tests with "hello"in their names
72
-
```
73
-
74
-
Installing the plugin in the project's plugin file is also required to enable the [grepFilterSpecs](#grepfilterspecs) feature.
75
-
76
-
### setupNodeEvents
77
-
78
-
To use this module with [Cypress v10.0.0](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-version-10-0) and above, add the following to your [config file](https://docs.cypress.io/guides/references/configuration):
55
+
**optional:** load and register this module from the [config file](https://docs.cypress.io/guides/references/configuration#setupNodeEvents):
79
56
80
57
```js
58
+
// cypress.config.js
81
59
{
82
60
e2e: {
83
61
setupNodeEvents(on, config) {
84
62
require('cypress-grep/src/plugin')(config);
85
-
86
63
return config;
87
64
},
88
65
}
89
66
}
90
67
```
91
68
69
+
Installing the plugin via `setupNodeEvents()` is required to enable the [grepFilterSpecs](#grepfilterspecs) feature.
70
+
92
71
## Use
93
72
94
73
Start grepping by title and tags:
@@ -138,7 +117,7 @@ Most likely you will pass these environment variables from the command line. For
138
117
$ npx cypress run --env grep=login,grepTags=smoke
139
118
```
140
119
141
-
You can use any way to modify the environment values `grep` and `grepTags`, except the run-time `Cypress.env('grep')` (because it is too late at run-time). You can set the `grep` value in the `cypress.json` file to run only tests with the substring `viewport` in their names
120
+
You can use any way to modify the environment values `grep` and `grepTags`, except the run-time `Cypress.env('grep')` (because it is too late at run-time). You can set the `grep` value in the [config file](https://docs.cypress.io/guides/references/configuration) to run only tests with the substring `viewport` in their names
142
121
143
122
```json
144
123
{
@@ -162,7 +141,7 @@ You can also set the grep and grepTags from the DevTools console while running C
162
141
163
142
### Disable grep
164
143
165
-
If you specify the `grep` parameters inside `cypress.json`file, you can disable it from the command line
144
+
If you specify the `grep` parameters inside the [config file](https://docs.cypress.io/guides/references/configuration), you can disable it from the command line
166
145
167
146
```
168
147
$ npx cypress run --env grep=,grepTags=,burn=
@@ -247,9 +226,9 @@ Note 2: the `grepFilterSpecs` option is only compatible with the positive `grep`
247
226
248
227
Note 3: if there are no files remaining after filtering, the plugin prints a warning and leaves all files unchanged to avoid the test runner erroring with "No specs found".
249
228
250
-
**Tip:** you can set this environment variable in the `cypress.json` file to enable it by default and skip using the environment variable:
229
+
**Tip:** you can set this environment variable in the [config file](https://docs.cypress.io/guides/references/configuration) file to enable it by default and skip using the environment variable:
251
230
252
-
```json
231
+
```js
253
232
{
254
233
"env": {
255
234
"grepFilterSpecs":true
@@ -277,7 +256,7 @@ cypress run --env grep="works 2",grepOmitFiltered=true
**Tip:** you can set this environment variable in the `cypress.json` file to enable it by default and skip using the environment variable:
259
+
**Tip:** you can set this environment variable in the config file (usually `cypress.config.js`) file to enable it by default and skip using the environment variable:
0 commit comments