forked from pmmmwh/react-refresh-webpack-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest-test-setup.js
30 lines (28 loc) · 921 Bytes
/
jest-test-setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Skips a test block conditionally.
* @param {boolean} condition The condition to skip the test block.
* @param {string} blockName The name of the test block.
* @param {import('@jest/types').Global.BlockFn} blockFn The test block function.
* @returns {void}
*/
describe.skipIf = (condition, blockName, blockFn) => {
if (condition) {
return describe.skip(blockName, blockFn);
}
return describe(blockName, blockFn);
};
/**
* Skips a test conditionally.
* @param {boolean} condition The condition to skip the test.
* @param {string} testName The name of the test.
* @param {import('@jest/types').Global.TestFn} fn The test function.
* @param {number} [timeout] The time to wait before aborting.
* @returns {void}
*/
test.skipIf = (condition, testName, fn, timeout) => {
if (condition) {
return test.skip(testName, fn);
}
return test(testName, fn, timeout);
};
it.skipIf = test.skipIf;