Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 117b2dd

Browse files
joshuajtwardAdam Murray
authored andcommitted
update to be a breaking change
1 parent c6f15c9 commit 117b2dd

File tree

9 files changed

+74
-126
lines changed

9 files changed

+74
-126
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ jobs:
4040
npx cypress-expect \
4141
--passing 1 --pending 2 \
4242
--spec cypress/integration/skip-spec.js \
43-
--config testFiles="skip-spec.js"
43+
--config specPattern="**/skip-spec.js"
4444
4545
# all tests are pending
4646
# because the grep tag is only used in "it.skip" tests
4747
- name: Run e2e skip tests with grep 🧪
4848
run: |
4949
npx cypress-expect \
5050
--spec cypress/integration/skip-spec.js \
51-
--config testFiles="skip-spec.js" \
51+
--config specPattern="**/skip-spec.js" \
5252
--env grep=pending \
5353
--expect expects/pending.json
5454
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
npx cypress-expect \
6363
--spec cypress/integration/config-spec.js \
64-
--config testFiles="config-spec.js" \
64+
--config specPattern="**/config-spec.js" \
6565
--env grep=@config \
6666
--expect expects/config-spec.json
6767
@@ -186,7 +186,7 @@ jobs:
186186
run: |
187187
npx cypress-expect \
188188
--spec cypress/integration/config-tags-spec.js \
189-
--config testFiles="config-tags-spec.js" \
189+
--config specPattern="**/config-tags-spec.js" \
190190
--env grepTags=config \
191191
--expect expects/config-tags-spec.json
192192
@@ -195,7 +195,7 @@ jobs:
195195
run: |
196196
npx cypress-expect \
197197
--spec cypress/integration/describe-tags-spec.js \
198-
--config testFiles="describe-tags-spec.js" \
198+
--config specPattern="**/describe-tags-spec.js" \
199199
--env grepTags=-@smoke \
200200
--expect expects/describe-tags-invert-spec.json
201201
@@ -204,7 +204,7 @@ jobs:
204204
run: |
205205
npx cypress-expect \
206206
--spec cypress/integration/describe-tags-spec.js \
207-
--config testFiles="describe-tags-spec.js" \
207+
--config specPattern="**/describe-tags-spec.js" \
208208
--env grepTags=@smoke \
209209
--expect expects/describe-tags-spec.json
210210
@@ -213,7 +213,7 @@ jobs:
213213
- name: Tags OR specs 🧪
214214
run: |
215215
npx cypress-expect \
216-
--config testFiles="tags/*.spec.js" \
216+
--config specPattern="**/tags/*.spec.js" \
217217
--env grepTags="high smoke" \
218218
--expect-exactly expects/tags-or.json
219219
@@ -224,29 +224,29 @@ jobs:
224224
CYPRESS_grepTags: 'high,smoke'
225225
run: |
226226
npx cypress-expect \
227-
--config testFiles="tags/*.spec.js" \
227+
--config specPattern="**/tags/*.spec.js" \
228228
--expect-exactly expects/tags-or.json
229229
230230
- name: Tags AND specs 🧪
231231
run: |
232232
npx cypress-expect \
233-
--config testFiles="tags/*.spec.js" \
233+
--config specPattern="**/tags/*.spec.js" \
234234
--env grepTags="high+smoke" \
235235
--expect-exactly expects/tags-and.json
236236
237237
# https://github.com/cypress-io/cypress-grep/issues/98
238238
- name: Tags OR specs with grepFilterSpecs=true 🧪
239239
run: |
240240
npx cypress-expect \
241-
--config testFiles="tags/*.spec.js" \
241+
--config specPattern="**/tags/*.spec.js" \
242242
--env grepTags="high regression",grepFilterSpecs=true \
243243
--expect-exactly expects/tags-or-filter.json
244244
245245
- name: Specify is an alias to it 🧪
246246
run: |
247247
npx cypress-expect \
248248
--spec cypress/integration/specify-spec.js \
249-
--config testFiles="specify-spec.js" \
249+
--config specPattern="**/specify-spec.js" \
250250
--env grep="works 2" \
251251
--expect-exactly expects/specify.json
252252
@@ -270,7 +270,7 @@ jobs:
270270
- name: Omit and skip combination 🧪
271271
run: |
272272
npx cypress-expect \
273-
--config testFiles="omit-and-skip-spec.js" \
273+
--config specPattern="**/omit-and-skip-spec.js" \
274274
--env grepTags="@us1",grepOmitFiltered=true \
275275
--expect-exactly expects/omit-and-skip.json
276276
@@ -293,31 +293,31 @@ jobs:
293293
run: |
294294
npx cypress-expect \
295295
--spec cypress/integration/nested-describe-spec.js \
296-
--config testFiles="nested-describe-spec.js" \
296+
--config specPattern="**/nested-describe-spec.js" \
297297
--env grepTags=@smoke \
298298
--expect expects/nested-describe-spec.json
299299
300300
- name: Nested describes inheriting tags with grep 🧪
301301
run: |
302302
npx cypress-expect \
303303
--spec cypress/integration/nested-describe-spec.js \
304-
--config testFiles="nested-describe-spec.js" \
304+
--config specPattern="**/nested-describe-spec.js" \
305305
--env grepTags="@smoke+@fast" \
306306
--expect expects/nested-describe-inheriting-tags-spec.json
307307
308308
- name: Nested describes inheriting grep name 🧪
309309
run: |
310310
npx cypress-expect \
311311
--spec cypress/integration/nested-describe-spec.js \
312-
--config testFiles="nested-describe-spec.js" \
312+
--config specPattern="**/nested-describe-spec.js" \
313313
--env grep="bottom runs too" \
314314
--expect expects/nested-describe-inheriting-names-spec.json
315315
316316
- name: Nested describes without grep 🧪
317317
run: |
318318
npx cypress-expect \
319319
--spec cypress/integration/nested-describe-spec.js \
320-
--config testFiles="nested-describe-spec.js" \
320+
--config specPattern="**/nested-describe-spec.js" \
321321
--env grepTags=@does-not-exist \
322322
--pending 2
323323
@@ -334,66 +334,66 @@ jobs:
334334
run: |
335335
npx cypress-expect \
336336
--spec cypress/integration/multiple-registrations.js \
337-
--config testFiles="multiple-registrations.js" \
337+
--config specPattern="**/multiple-registrations.js" \
338338
--env grep="hello world",burn=3 \
339339
--expect expects/multiple-registrations.json
340340
341341
- name: cypress-each test 🧪
342342
run: |
343343
npx cypress-expect \
344344
--spec cypress/integration/each-spec.js \
345-
--config testFiles="each-spec.js" \
345+
--config specPattern="**/each-spec.js" \
346346
--env grep="for 2" \
347347
--expect expects/each-spec.json
348348
349349
- name: burning without grep 🧪
350350
run: |
351351
npx cypress-expect \
352352
--spec cypress/integration/burn-spec.js \
353-
--config testFiles="burn-spec.js" \
353+
--config specPattern="**/burn-spec.js" \
354354
--env burn=5 \
355355
--expect expects/burn-spec.json
356356
357357
- name: preserves the test context 🧪
358358
run: |
359359
npx cypress-expect \
360360
--spec cypress/integration/this-spec.js \
361-
--config testFiles="this-spec.js" \
361+
--config specPattern="**/this-spec.js" \
362362
--env burn=3 \
363363
--expect expects/this-spec.json
364364
365365
- name: filter the specs first 🧪
366366
run: |
367367
npx cypress-expect \
368-
--config testFiles="**/*.js" \
368+
--config specPattern="**/*.js" \
369369
--env grep="outside any suites",grepFilterSpecs=true \
370370
--expect-exactly expects/grep-filter-specs.json
371371
372372
- name: filter the specs first by tag 🧪
373373
run: |
374374
npx cypress-expect \
375-
--config testFiles="**/*.js" \
375+
--config specPattern="**/*.js" \
376376
--env grepTags=@smoke,grepFilterSpecs=true \
377377
--expect-exactly expects/grep-filter-specs-tag.json
378378
379379
- name: run untagged tests 🧪
380380
run: |
381381
npx cypress-expect \
382-
--config testFiles="**/spec.js" \
382+
--config specPattern="**/spec.js" \
383383
--env grepUntagged=true \
384384
--expect-exactly expects/grep-untagged.json
385385
386386
- name: run untagged tests in blocks 🧪
387387
run: |
388388
npx cypress-expect \
389-
--config testFiles="**/describe-tags-spec.js" \
389+
--config specPattern="**/describe-tags-spec.js" \
390390
--env grepUntagged=true \
391391
--expect-exactly expects/describe-tags-spec-untagged.json
392392
393393
- name: filter TypeScript spec 🧪
394394
run: |
395395
npx cypress-expect \
396-
--config testFiles="**/ts-spec.ts" \
396+
--config specPattern="**/ts-spec.ts" \
397397
--env grep=loads,grepOmitFiltered=true,grepFilterSpecs=true \
398398
--expect-exactly expects/ts-spec.json
399399
@@ -402,27 +402,27 @@ jobs:
402402
npx cypress-expect \
403403
--env grepTags=@staging \
404404
--spec cypress/integration/before-spec.js \
405-
--config testFiles="before-spec.js" \
405+
--config specPattern="**/before-spec.js" \
406406
--expect ./expects/before.json
407407
408408
- name: inherits parent tags 🧪
409409
run: |
410410
npx cypress-expect \
411-
--config testFiles="**/inherits-tag-spec.js" \
411+
--config specPattern="**/inherits-tag-spec.js" \
412412
--env grepTags="@sanity+@screen-b" \
413413
--expect-exactly expects/inherits-tag-spec.json
414414
415415
- name : explicit not tags prevent test from running
416416
run: |
417417
npx cypress-expect \
418-
--config testFiles="**/explicit-spec.js" \
418+
--config specPattern="**/explicit-spec.js" \
419419
--env grepTags="@tag1 --@tag2" \
420420
--expect-exactly expects/explicit-spec.json
421421
422422
- name : explicit not tags work with omitFiltered
423423
run: |
424424
npx cypress-expect \
425-
--config testFiles="**/explicit-spec.js" \
425+
--config specPattern="**/explicit-spec.js" \
426426
--env grepTags="@tag1 --@tag2",grepOmitFiltered=true \
427427
--expect-exactly expects/explicit-omit-spec.json
428428

README.md

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ npm i -D cypress-grep
3434
yarn add -D cypress-grep
3535
```
3636

37+
### Support file
3738
**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:
3839

3940
```js
@@ -48,47 +49,25 @@ import registerCypressGrep from 'cypress-grep'
4849
registerCypressGrep()
4950
```
5051

51-
### Plugin file
5252

53-
**optional:** load and register this module from the [plugin file](https://on.cypress.io/writing-and-organizing-tests#Plugins-file)
53+
### Config file
5454

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):
7956

8057
```js
58+
// cypress.config.js
8159
{
8260
e2e: {
8361
setupNodeEvents(on, config) {
8462
require('cypress-grep/src/plugin')(config);
85-
8663
return config;
8764
},
8865
}
8966
}
9067
```
9168

69+
Installing the plugin via `setupNodeEvents()` is required to enable the [grepFilterSpecs](#grepfilterspecs) feature.
70+
9271
## Use
9372

9473
Start grepping by title and tags:
@@ -138,7 +117,7 @@ Most likely you will pass these environment variables from the command line. For
138117
$ npx cypress run --env grep=login,grepTags=smoke
139118
```
140119

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
142121

143122
```json
144123
{
@@ -162,7 +141,7 @@ You can also set the grep and grepTags from the DevTools console while running C
162141

163142
### Disable grep
164143

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
166145

167146
```
168147
$ npx cypress run --env grep=,grepTags=,burn=
@@ -247,9 +226,9 @@ Note 2: the `grepFilterSpecs` option is only compatible with the positive `grep`
247226

248227
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".
249228

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:
251230

252-
```json
231+
```js
253232
{
254233
"env": {
255234
"grepFilterSpecs": true
@@ -277,7 +256,7 @@ cypress run --env grep="works 2",grepOmitFiltered=true
277256

278257
![Only running tests remaining](./images/omit-pending.png)
279258

280-
**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:
281260

282261
```json
283262
{

cypress.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
defaultCommandTimeout: 1000,
6+
setupNodeEvents(on, config) {
7+
require('./src/plugin')(config)
8+
return config
9+
},
10+
specPattern: '**/spec.js',
11+
},
12+
fixturesFolder: false,
13+
video: false,
14+
})

cypress.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

cypress/plugins/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
/// <reference types="cypress" />
33

4-
import cypressGrep from '../..'
4+
import cypressGrep from '../../src/support'
55
// register the grep feature
66
// https://github.com/cypress-io/cypress-grep
77
cypressGrep()

0 commit comments

Comments
 (0)