Answered
I need to run a specific Cypress test in each browser besides Google Chrome.
So, when Cypress is using Chrome as the browser it runs tests in, this specific test would not be ran.
In my Cypress code, I could then do something like this:
if (!chrome) {
// run the test
}
How can I do this in Cypress?
You can use the Cypress.browser.name
value. It will return the name of the browser Cypress is currently using.
const isChrome = Cypress.browser.name === "chrome"
if (Cypress.browser.name !== "chrome") {
// run the test
}
The test inside the if
statement will not run if Cypress is using the Chrome browser.
Cypress has @cypress/skip-test NPM package you can use for this.
It provides a skipOn()
method you could use to skip a test when running in the Chrome browser:
it('skips on Chrome', () => {
skipOn('chrome')
})