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.
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",
...