Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 90ec292

Browse files
committed
feat: use new Cypress.isBrowser method if available
1 parent 987c436 commit 90ec292

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="cypress" />
2+
import { skipOn } from '../..'
3+
4+
skipOn('firefox', () => {
5+
it('runs the current test', () => {
6+
expect(Cypress.browser.name !== 'firefox', 'should not be firefox!')
7+
})
8+
})

index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

44
const { _ } = Cypress
55

6+
const checkBrowserName = name => {
7+
if ('isBrowser' in Cypress) {
8+
// use the new v4.0 method
9+
// @ts-ignore
10+
return Cypress.isBrowser(name)
11+
} else {
12+
return Cypress.browser.name === name
13+
}
14+
}
15+
616
/**
717
* Cleans up the passed name which could be browser, platform or other.
818
* @param {string} name The environment or platform or something else, like url
@@ -124,10 +134,10 @@ const skipOn = (name, cb) => {
124134
}
125135

126136
if (isBrowser(normalizedName)) {
127-
if (Cypress.browser.name !== normalizedName) {
137+
if (!checkBrowserName(normalizedName)) {
128138
return cb()
129139
}
130-
return
140+
return it(`Skipping test(s) on ${normalizedName}`)
131141
}
132142

133143
if (!matchesUrlPart(normalizedName)) {

0 commit comments

Comments
 (0)