Repository: facebook/react
File: scripts/jest/preprocessor.js (JavaScript)

Code before:
    }
    if (filePath.match(/\.ts$/) && !filePath.match(/\.d\.ts$/)) {
      return {code: tsPreprocessor.compile(src, filePath)};
    }
    if (filePath.match(/\.json$/)) {
      return {code: src};
    }
    if (!filePath.match(/\/third_party\//)) {
      // for test files, we also apply the async-await transform, but we want to
      // make sure we don't accidentally apply that transform to product code.
      const isTestFile = !!filePath.match(/\/__tests__\//);
      const isInDevToolsPackages = !!filePath.match(
        /\/packages\/react-devtools.*\//
      );
      const plugins = [].concat(babelOptions.plugins);
      if (isTestFile && isInDevToolsPackages) {
        plugins.push(pathToTransformReactVersionPragma);
      }

      // This is only for React DevTools tests with React 16.x
      // `react/jsx-dev-runtime` and `react/jsx-runtime` are included in the package starting from v17
      // Technically 16.14 and 15.7 have the new runtime but we're not testing those
      if (
        semver.gte(ReactVersionTestingAgainst, '15.0.0') &&
        semver.lt(ReactVersionTestingAgainst, '17.0.0')
      ) {
        plugins.push(
          [
            require.resolve('@babel/plugin-transform-react-jsx'),
            {runtime: 'classic'},
          ],
          require.resolve('@babel/plugin-transform-react-jsx-source')
        );
      } else {
        plugins.push([
          process.env.NODE_ENV === 'development'
            ? require.resolve('@babel/plugin-transform-react-jsx-development')
            : require.resolve('@babel/plugin-transform-react-jsx'),
          // The "automatic" runtime corresponds to react/jsx-runtime. "classic"
          // would be React.createElement.
          {runtime: 'automatic'},
        ]);
      }

      plugins.push(pathToTransformLazyJSXImport);

      let sourceAst = hermesParser.parse(src, {babel: true});
      return {
        code: babel.transformFromAstSync(
          sourceAst,
          src,

Review comment (suggestion):
I don't trust how SemVer comparisons works with `0.0.0-experimental` ranges so I flipped these branches to only use classic runtime for this particular range. The previousl `else` branch silently flipped to modern runtime when the defaults changed in Babel.

Code after:
    }
    if (filePath.match(/\.ts$/) && !filePath.match(/\.d\.ts$/)) {
      return {code: tsPreprocessor.compile(src, filePath)};
    }
    if (filePath.match(/\.json$/)) {
      return {code: src};
    }
    if (!filePath.match(/\/third_party\//)) {
      // for test files, we also apply the async-await transform, but we want to
      // make sure we don't accidentally apply that transform to product code.
      const isTestFile = !!filePath.match(/\/__tests__\//);
      const isInDevToolsPackages = !!filePath.match(
        /\/packages\/react-devtools.*\//
      );
      const plugins = [].concat(babelOptions.plugins);
      if (isTestFile && isInDevToolsPackages) {
        plugins.push(pathToTransformReactVersionPragma);
      }

      // This is only for React DevTools tests with React 16.x
      // `react/jsx-dev-runtime` and `react/jsx-runtime` are included in the package starting from v17
      // Technically 16.14 and 15.7 have the new runtime but we're not testing those versions.
      if (
        semver.gte(ReactVersionTestingAgainst, '15.0.0') &&
        semver.lt(ReactVersionTestingAgainst, '17.0.0')
      ) {
        plugins.push(
          [
            require.resolve('@babel/plugin-transform-react-jsx'),
            {runtime: 'classic'},
          ],
          require.resolve('@babel/plugin-transform-react-jsx-source')
        );
      } else {
        plugins.push([
          process.env.NODE_ENV === 'development'
            ? require.resolve('@babel/plugin-transform-react-jsx-development')
            : require.resolve('@babel/plugin-transform-react-jsx'),
          // The "automatic" runtime corresponds to react/jsx-runtime. "classic"
          // would be React.createElement.
          {runtime: 'automatic'},
        ]);
      }

      plugins.push(pathToTransformLazyJSXImport);

      let sourceAst = hermesParser.parse(src, {babel: true});
      return {
        code: babel.transformFromAstSync(
          sourceAst,
          src,