Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
eulersson committed Sep 19, 2024
2 parents 8f3fc42 + a4ac9de commit d073a21
Show file tree
Hide file tree
Showing 24 changed files with 5,016 additions and 37,997 deletions.
14 changes: 8 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
lint:
description: Checks the code formatting
docker:
- image: cimg/node:20.9.0
- image: cimg/node:22.8.0
environment:
# we don't need Cypress to check code style
CYPRESS_INSTALL_BINARY: '0'
Expand Down Expand Up @@ -40,11 +40,11 @@ jobs:
steps:
- checkout
- run:
name: Install node 16
command: nvm install 16.16.0
name: Install node 20
command: nvm install 20.12.1
- run:
name: Use node 16
command: nvm use 16.16.0
name: Use node 20
command: nvm use 20.12.1
- run:
name: Install deps for code coverage
command: npm ci
Expand All @@ -71,7 +71,7 @@ jobs:
publish:
description: Publishes the new version of the plugin to NPM
docker:
- image: cimg/node:20.9.0
- image: cimg/node:22.8.0
environment:
# we don't need Cypress to do the release
CYPRESS_INSTALL_BINARY: '0'
Expand Down Expand Up @@ -152,6 +152,7 @@ workflows:
- exclude-files
- frontend
- fullstack
- multiple-backends
- one-spec
- same-folder
- support-files
Expand Down Expand Up @@ -179,6 +180,7 @@ workflows:
- test-exclude-files
- test-frontend
- test-fullstack
- test-multiple-backends
- test-one-spec
- test-same-folder
- test-support-files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk_sca_scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
- name: Perform SCA Scan
continue-on-error: false
run: |
snyk test --all-projects --detection-depth=4 --exclude=docker,Dockerfile --severity-threshold=critical
snyk test --all-projects --detection-depth=4 --exclude=docker,Dockerfile,test-apps --severity-threshold=critical
env:
SNYK_TOKEN: ${{ secrets.SNYK_API_TOKEN }}
83 changes: 71 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ npm install -D @cypress/code-coverage

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

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

```js
// cypress/support/e2e.js
import '@cypress/code-coverage/support'
```

Register tasks in your `cypress/plugins/index.js` file.

```js
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)

// add other tasks to be registered here

// IMPORTANT to return the config object
// with the any changed environment variables
return config
}
// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
// setupNodeEvents can be defined in either
// the e2e or component configuration
e2e: {
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config)
// include any other plugin code...

// It's IMPORTANT to return the config object
// with any changed environment variables
return config
},
},
})
```

## Instrument your application
Expand Down Expand Up @@ -207,6 +214,18 @@ if (global.__coverage__) {
}
```

Or if you have multiple servers from which you are wanting to gather code coverage, you can pass an array to `url` as well:

```json
{
"env": {
"codeCoverage": {
"url": ["http://localhost:3000/__coverage__", "http://localhost:3001/__coverage__"]
}
}
}
```

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.

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

## Migrations

### Cypress v9 to v10

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).

```js
// BEFORE
// Register tasks in your `cypress/plugins/index.js` file.

module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)

// add other tasks to be registered here

// IMPORTANT to return the config object
// with the any changed environment variables
return config
}
```

```js
// AFTER
// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
// setupNodeEvents can be defined in either
// the e2e or component configuration
e2e: {
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config)
// include any other plugin code...

// It's IMPORTANT to return the config object
// with any changed environment variables
return config
},
},
})
```

### v2 to v3

Change the plugins file `cypress/plugins/index.js`
Expand Down
Loading

0 comments on commit d073a21

Please sign in to comment.