From 2b8bf5455070df15f3e284ede434f179e6b4811e Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Mon, 4 Dec 2023 14:38:36 -0500 Subject: [PATCH 1/2] Update Readme with v10 instructions --- README.md | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8eae2f3a..1a1383c9 100644 --- a/README.md +++ b/README.md @@ -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 From e203f8f8e444d2bd0340b003792311512e7f1f23 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Mon, 4 Dec 2023 16:08:37 -0500 Subject: [PATCH 2/2] Added migration info for v9->v10+ --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 1a1383c9..8aed8d04 100644 --- a/README.md +++ b/README.md @@ -452,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`