0

This problem occurs when I attempt to run unit tests with React Testing Library using Jest. I'm working on a React-TypeScript project and in the currently testing .tsx file have some images with .svg extension. When I try to run npm run test <filename.spec.tsx> I'm getting the following error.

enter image description here

This my jest.config.ts file:

export default {
  preset: '../../../jest.preset.js',
  transform: {
    '^.+\\.[tj]sx?$': 'babel-jest',
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
  coverageDirectory: '../../../coverage/libs/shared/dashboard-widgets',
};

package.json file:

...
"devDependencies": {
    "@babel/core": "7.12.13",
    "@babel/plugin-transform-modules-commonjs": "^7.21.2",
    "@babel/preset-flow": "^7.18.6",
    "@babel/preset-react": "^7.18.6",
    "@babel/preset-typescript": "^7.21.0",
...
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Does this answer your question? [Babel throwing Support for the experimental syntax 'jsx' isn't currently enabled](https://stackoverflow.com/questions/62820035/babel-throwing-support-for-the-experimental-syntax-jsx-isnt-currently-enabled) – Ben Smith Feb 24 '23 at 09:58

0 Answers0