@@ -31,9 +31,10 @@ global.process.env.LIGHT_MODE_DIMMED_ERROR_COLOR =
31
31
LIGHT_MODE_DIMMED_ERROR_COLOR ;
32
32
global . process . env . LIGHT_MODE_DIMMED_LOG_COLOR = LIGHT_MODE_DIMMED_LOG_COLOR ;
33
33
34
+ const ReactVersionTestingAgainst = process . env . REACT_VERSION || ReactVersion ;
35
+
34
36
global . _test_react_version = ( range , testName , callback ) => {
35
- const reactVersion = process . env . REACT_VERSION || ReactVersion ;
36
- const shouldPass = semver . satisfies ( reactVersion , range ) ;
37
+ const shouldPass = semver . satisfies ( ReactVersionTestingAgainst , range ) ;
37
38
38
39
if ( shouldPass ) {
39
40
test ( testName , callback ) ;
@@ -43,8 +44,7 @@ global._test_react_version = (range, testName, callback) => {
43
44
} ;
44
45
45
46
global . _test_react_version_focus = ( range , testName , callback ) => {
46
- const reactVersion = process . env . REACT_VERSION || ReactVersion ;
47
- const shouldPass = semver . satisfies ( reactVersion , range ) ;
47
+ const shouldPass = semver . satisfies ( ReactVersionTestingAgainst , range ) ;
48
48
49
49
if ( shouldPass ) {
50
50
// eslint-disable-next-line jest/no-focused-tests
@@ -71,12 +71,14 @@ global._test_ignore_for_react_version = (testName, callback) => {
71
71
// Longer term we should migrate all our tests away from using require() and
72
72
// resetModules, and use import syntax instead so this kind of thing doesn't
73
73
// happen.
74
- lazyRequireFunctionExports ( 'react/jsx-dev-runtime' ) ;
74
+ if ( semver . gte ( ReactVersionTestingAgainst , '17.0.0' ) ) {
75
+ lazyRequireFunctionExports ( 'react/jsx-dev-runtime' ) ;
75
76
76
- // TODO: We shouldn't need to do this in the production runtime, but until
77
- // we remove string refs they also depend on the shared state object. Remove
78
- // once we remove string refs.
79
- lazyRequireFunctionExports ( 'react/jsx-runtime' ) ;
77
+ // TODO: We shouldn't need to do this in the production runtime, but until
78
+ // we remove string refs they also depend on the shared state object. Remove
79
+ // once we remove string refs.
80
+ lazyRequireFunctionExports ( 'react/jsx-runtime' ) ;
81
+ }
80
82
81
83
function lazyRequireFunctionExports ( moduleName ) {
82
84
jest . mock ( moduleName , ( ) => {
0 commit comments