Skip to content

feat: set flag from plugins task that they were registered #180

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 8 commits into from
Apr 6, 2020

Conversation

bahmutov
Copy link
Contributor

@bahmutov bahmutov commented Apr 6, 2020

To avoid support hooks "blindly" trying to call cy.task('resetCoverage') and other hooks if the plugins has never registered them

BREAKING CHANGE: the task sets an environment variable and needs
to return its config. The new registration thus looks like this

// your plugins file
module.exports = (on, config) => {
  require('cypress/code-coverage/task')(on, config)
  // IMPORTANT to return the config object
  // with the any changed environment variables
  return config
}

Support code can check variable Cypress.env('codeCoverageTasksRegistered')
before calling cy.task

closes #179

Related

To disable any code coverage actions, set environment variable coverage: false in cypress.json or via environment variable or via CLI

bahmutov added 3 commits April 6, 2020 09:59
BREAKING CHANGE: the task sets an environment variable and needs
to return its config. The new registration thus looks like this

```js
// your plugins file
module.exports = (on, config) => {
  require('cypress/code-coverage/task')(on, config)
  // IMPORTANT to return the config object
  // with the any changed environment variables
  return config
}
```

Support code can check variable `Cypress.env('codeCoverageTasksRegistered')`
before calling `cy.task`
@bahmutov bahmutov requested a review from flotwig April 6, 2020 14:15
@bahmutov bahmutov merged commit 288b61d into master Apr 6, 2020
@bahmutov
Copy link
Contributor Author

bahmutov commented Apr 6, 2020

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

rndmerle pushed a commit to rndmerle/code-coverage that referenced this pull request Apr 25, 2020
…o#180)

* feat: set flag from plugins task that they were registered

BREAKING CHANGE: the task sets an environment variable and needs
to return its config. The new registration thus looks like this

```js
// your plugins file
module.exports = (on, config) => {
  require('cypress/code-coverage/task')(on, config)
  // IMPORTANT to return the config object
  // with the any changed environment variables
  return config
}
```

Support code can check variable `Cypress.env('codeCoverageTasksRegistered')`
before calling `cy.task`

* update readme

* update examples

* add small plugins file

* update readme

* add example using plugins and support

* add new example to CI

* no need to start server in the example
@emilyrohrbough emilyrohrbough deleted the set-env-var-on-registration branch March 22, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support should not send coverage unless plugins task has been registered
1 participant