Skip to content

Update Readme with v10 instructions #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 59 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 @@ -445,6 +452,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