在 React 组件中导入资产(例如,从“../../../assets/img/logo.png 导入徽标”)给出了这样的错误
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){ PNG 语法错误
:ScriptTransformer._transformAndBuildScript 处的令牌无效或意外(node_modules/jest-runtime/build/script_transformer.js:305 :17)
我的笑话配置是
"jest": {
"testRegex": ".*\\.spec\\.js$",
"moduleFileExtensions": [
"js",
"jsx",
"json"
],
"moduleDirectories": [
"node_modules",
"src",
"assets"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less|scss)$": "<rootDir>/__mocks__/styleMock.js"
},
"verbose": true,
"bail": true
}
我错过了什么?