在 React 组件中导入资产 (例如,从”. ./. ./. ./asset/img/logo.png 导入徽标) 给出了这样的错误
({“ Object.”: function (模块,导出,要求,_ _ dirname,_ _ filename,global,jest){ PNG
SyntaxError: 无效或意外的令牌 在 ScriptTransformer. _ formAndBuildScript (node _ module/jest-running/build/script _ former.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
}
我错过了什么?