main
js 43 lines 1.19 KB
Raw
1 'use strict';
2
3 const semver = require('semver');
4 const {ReactVersion} = require('../../../ReactVersions');
5
6 // DevTools stores preferences between sessions in localStorage
7 if (!global.hasOwnProperty('localStorage')) {
8 global.localStorage = require('local-storage-fallback').default;
9 }
10
11 // Mimic the global we set with Webpack's DefinePlugin
12 global.__DEV__ = process.env.NODE_ENV !== 'production';
13 global.__TEST__ = true;
14 global.__IS_FIREFOX__ = false;
15 global.__IS_CHROME__ = false;
16 global.__IS_EDGE__ = false;
17 global.__IS_NATIVE__ = false;
18
19 const ReactVersionTestingAgainst = process.env.REACT_VERSION || ReactVersion;
20
21 global._test_react_version = (range, testName, callback) => {
22 const shouldPass = semver.satisfies(ReactVersionTestingAgainst, range);
23
24 if (shouldPass) {
25 test(testName, callback);
26 } else {
27 test.skip(testName, callback);
28 }
29 };
30
31 global._test_react_version_focus = (range, testName, callback) => {
32 const shouldPass = semver.satisfies(ReactVersionTestingAgainst, range);
33
34 if (shouldPass) {
35 test.only(testName, callback);
36 } else {
37 test.skip(testName, callback);
38 }
39 };
40
41 global._test_ignore_for_react_version = (testName, callback) => {
42 test.skip(testName, callback);
43 };