jest doesn’t know how to load other file extensions than js/jsx,you need to find the jest.config.js and add transformer for svg files.
"transform": {
"^.+\\.tsx?$": "ts-jest",
"^.+\\.svg$": "<rootDir>/svgTransform.js"
},
and create the svgTransform.js
file (see Custom transformers) in your root directory with the following content:
// See https://stackoverflow.com/questions/58603201/jest-cannot-load-svg-file
module.exports = {
process() {
return {
code: `module.exports = {};`,
};
},
getCacheKey() {
// The output is always the same.
return "svgTransform";
},
};