diff --git a/README.md b/README.md index 43bc17314..1fc287cd2 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ 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 diff --git a/support.js b/support.js index 9573ae136..c6458da47 100644 --- a/support.js +++ b/support.js @@ -220,8 +220,16 @@ const registerHooks = () => { // to disable code coverage commands and save time // pass environment variable coverage=false // cypress run --env coverage=false +// or +// CYPRESS_coverage=false cypress run // see https://on.cypress.io/environment-variables -if (Cypress.env('coverage') === false) { + +// to avoid "coverage" env variable being case-sensitive, convert to lowercase +const cyEnvs = Cypress._.mapKeys(Cypress.env(), (value, key) => + key.toLowerCase() +) + +if (cyEnvs.coverage === false) { console.log('Skipping code coverage hooks') } else if (Cypress.env('codeCoverageTasksRegistered') !== true) { // register a hook just to log a message