Skip to content

Commit d073a21

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8f3fc42 + a4ac9de commit d073a21

File tree

24 files changed

+5016
-37997
lines changed

24 files changed

+5016
-37997
lines changed

.circleci/config.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
lint:
1010
description: Checks the code formatting
1111
docker:
12-
- image: cimg/node:20.9.0
12+
- image: cimg/node:22.8.0
1313
environment:
1414
# we don't need Cypress to check code style
1515
CYPRESS_INSTALL_BINARY: '0'
@@ -40,11 +40,11 @@ jobs:
4040
steps:
4141
- checkout
4242
- run:
43-
name: Install node 16
44-
command: nvm install 16.16.0
43+
name: Install node 20
44+
command: nvm install 20.12.1
4545
- run:
46-
name: Use node 16
47-
command: nvm use 16.16.0
46+
name: Use node 20
47+
command: nvm use 20.12.1
4848
- run:
4949
name: Install deps for code coverage
5050
command: npm ci
@@ -71,7 +71,7 @@ jobs:
7171
publish:
7272
description: Publishes the new version of the plugin to NPM
7373
docker:
74-
- image: cimg/node:20.9.0
74+
- image: cimg/node:22.8.0
7575
environment:
7676
# we don't need Cypress to do the release
7777
CYPRESS_INSTALL_BINARY: '0'
@@ -152,6 +152,7 @@ workflows:
152152
- exclude-files
153153
- frontend
154154
- fullstack
155+
- multiple-backends
155156
- one-spec
156157
- same-folder
157158
- support-files
@@ -179,6 +180,7 @@ workflows:
179180
- test-exclude-files
180181
- test-frontend
181182
- test-fullstack
183+
- test-multiple-backends
182184
- test-one-spec
183185
- test-same-folder
184186
- test-support-files

.github/workflows/snyk_sca_scan.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
- name: Perform SCA Scan
2727
continue-on-error: false
2828
run: |
29-
snyk test --all-projects --detection-depth=4 --exclude=docker,Dockerfile --severity-threshold=critical
29+
snyk test --all-projects --detection-depth=4 --exclude=docker,Dockerfile,test-apps --severity-threshold=critical
3030
env:
3131
SNYK_TOKEN: ${{ secrets.SNYK_API_TOKEN }}

README.md

+71-12
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ npm install -D @cypress/code-coverage
1010

1111
**Note:** This plugin assumes that `cypress` is a peer dependency already installed in your project.
1212

13-
Add to your `cypress/support/index.js` file.
13+
Then add the code below to the `supportFile` and `setupNodeEvents` function.
1414

1515
```js
16+
// cypress/support/e2e.js
1617
import '@cypress/code-coverage/support'
1718
```
1819

19-
Register tasks in your `cypress/plugins/index.js` file.
20-
2120
```js
22-
module.exports = (on, config) => {
23-
require('@cypress/code-coverage/task')(on, config)
24-
25-
// add other tasks to be registered here
26-
27-
// IMPORTANT to return the config object
28-
// with the any changed environment variables
29-
return config
30-
}
21+
// cypress.config.js
22+
const { defineConfig } = require('cypress')
23+
24+
module.exports = defineConfig({
25+
// setupNodeEvents can be defined in either
26+
// the e2e or component configuration
27+
e2e: {
28+
setupNodeEvents(on, config) {
29+
require('@cypress/code-coverage/task')(on, config)
30+
// include any other plugin code...
31+
32+
// It's IMPORTANT to return the config object
33+
// with any changed environment variables
34+
return config
35+
},
36+
},
37+
})
3138
```
3239

3340
## Instrument your application
@@ -207,6 +214,18 @@ if (global.__coverage__) {
207214
}
208215
```
209216

217+
Or if you have multiple servers from which you are wanting to gather code coverage, you can pass an array to `url` as well:
218+
219+
```json
220+
{
221+
"env": {
222+
"codeCoverage": {
223+
"url": ["http://localhost:3000/__coverage__", "http://localhost:3001/__coverage__"]
224+
}
225+
}
226+
}
227+
```
228+
210229
That should be enough - the code coverage from the server will be requested at the end of the test run and merged with the client-side code coverage, producing a combined report.
211230

212231
### expectBackendCoverageOnly
@@ -445,6 +464,46 @@ Look up the list of examples under the GitHub topic [cypress-code-coverage-examp
445464

446465
## Migrations
447466

467+
### Cypress v9 to v10
468+
469+
With the removal of the `plugins` directory in Cypress version 10+, you'll need to add all of your configuration into the configuration file (`cypress.config.js` by default).
470+
471+
```js
472+
// BEFORE
473+
// Register tasks in your `cypress/plugins/index.js` file.
474+
475+
module.exports = (on, config) => {
476+
require('@cypress/code-coverage/task')(on, config)
477+
478+
// add other tasks to be registered here
479+
480+
// IMPORTANT to return the config object
481+
// with the any changed environment variables
482+
return config
483+
}
484+
```
485+
486+
```js
487+
// AFTER
488+
// cypress.config.js
489+
const { defineConfig } = require('cypress')
490+
491+
module.exports = defineConfig({
492+
// setupNodeEvents can be defined in either
493+
// the e2e or component configuration
494+
e2e: {
495+
setupNodeEvents(on, config) {
496+
require('@cypress/code-coverage/task')(on, config)
497+
// include any other plugin code...
498+
499+
// It's IMPORTANT to return the config object
500+
// with any changed environment variables
501+
return config
502+
},
503+
},
504+
})
505+
```
506+
448507
### v2 to v3
449508

450509
Change the plugins file `cypress/plugins/index.js`

0 commit comments

Comments
 (0)