You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
534 B

11 months ago
  1. 'use strict';
  2. const babelJest = require('babel-jest').default;
  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. });