cypress-skip-test icon indicating copy to clipboard operation
cypress-skip-test copied to clipboard

How to include/exclude a test based of custom value

Open mellis481 opened this issue 5 years ago • 1 comments

There seems to be a finite list of values that can be passed in to skipOn and onlyOn (eg. 'localhost', 'mac', etc.) which don't seem to be documented anywhere. I also see in the docs that you can use the CYPRESS_ENVIRONMENT value too. I'm looking to be able to use a custom value/expression from my cypress.json file. Eg.

{
  "env": {
    "includedTests": "platform"
  }
}

Is there a way to do something like this:

skipOn(Cypress.env.includedTests === 'platform')

mellis481 avatar Sep 30 '20 13:09 mellis481

onlyOn support a boolean argument so you can use it for the inverse case:

cy.onlyOn(Cypress.env.includedTests !== 'platform')

See https://github.com/cypress-io/cypress-skip-test#boolean-flag

csvan avatar Dec 11 '20 21:12 csvan