Run a Cypress test in all browsers besides Chrome?

Answered
nick asked this question 2 months ago
nick on Mar 15

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?

3 suggested answers
looper003 17 days ago

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"
0 replies
coderguy 17 days ago
if (Cypress.browser.name !== "chrome") {
  // run the test
}

The test inside the if statement will not run if Cypress is using the Chrome browser.

0 replies
yaboy01 16 days ago

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')
})
0 replies
Answered