Skip to content

Commit d2c1a23

Browse files
committed
test(journeys): add skip in browser helpers
1 parent 0acac0e commit d2c1a23

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/journeys/lib/browser.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* global: browser */
2+
function inFirefox() {
3+
return browser.desiredCapabilities.browserName === 'firefox';
4+
}
5+
6+
function inChrome() {
7+
return browser.desiredCapabilities.browserName === 'chrome';
8+
}
9+
10+
/**
11+
* Wrap the desired mochaMethod with `skipInFirefox` to prevent the
12+
* corresponding test or group of tests from running in Firefox.
13+
* example:
14+
* `skipInFirefox(it)('does a thing that does not work in Firefox')`
15+
* @param {Function} mochaMethod `it` or `describe`
16+
* @returns {Function} mochaMethod or mochaMethod.skip
17+
*/
18+
export function skipInFirefox(mochaMethod) {
19+
// If mochaMethod doesn't have a skip method, assume that mochaMethod is
20+
// already either a .skip or a .only
21+
if (!mochaMethod.skip) {
22+
return mochaMethod;
23+
}
24+
25+
return inFirefox() ? mochaMethod.skip : mochaMethod;
26+
}
27+
28+
/**
29+
* Wrap the desired mochaMethod with `skipInChrome` to prevent the
30+
* corresponding test or group of tests from running in Chrome.
31+
* example:
32+
* `skipInChrome(it)('does a thing that does not work in Chrome')`
33+
* @param {Function} mochaMethod `it` or `describe`
34+
* @returns {Function} mochaMethod or mochaMethod.skip
35+
*/
36+
export function skipInChrome(mochaMethod) {
37+
// If mochaMethod doesn't have a skip method, assume that mochaMethod is
38+
// already either a .skip or a .only
39+
if (!mochaMethod.skip) {
40+
return mochaMethod;
41+
}
42+
43+
return inChrome() ? mochaMethod.skip : mochaMethod;
44+
}

0 commit comments

Comments
 (0)