Answered
I need to run a specific Cypress test in each browser besides Firefox.
So, when Cypress is using Firefox 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 (!firefox) {
// run the test
}
How can I do this in Cypress?
You can get the name of the current browser being used by Cypress via Cypress.browser.name
. This will return a browser name in the "firefox"
, "chrome"
, "electron"
, etc. format.
To only run a test in browsers that are not Firefox, you can do this:
if (Cypress.browser.name !== "firefox") {
// run the test
}
You use the Cypress.browser.name
value.
const isFirefox = Cypress.browser.name === "firefox"
Cypress has @cypress/skip-test NPM package you can use for this.
It provides a skipOn()
method you could use to skip Firefox:
it('skips on Firefox', () => {
skipOn('firefox')
})