babelTransform.js 526 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const babelJest = require('babel-jest');
  3. const hasJsxRuntime = (() => {
  4. if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
  5. return false;
  6. }
  7. try {
  8. require.resolve('react/jsx-runtime');
  9. return true;
  10. } catch (e) {
  11. return false;
  12. }
  13. })();
  14. module.exports = babelJest.createTransformer({
  15. presets: [
  16. [
  17. require.resolve('babel-preset-react-app'),
  18. {
  19. runtime: hasJsxRuntime ? 'automatic' : 'classic',
  20. },
  21. ],
  22. ],
  23. babelrc: false,
  24. configFile: false,
  25. });