获取stacktrace
SyntaxError: The string did not match the expected pattern.
at XMLHttpRequest.open (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:482:15)
at http (node_modules/httpplease/lib/index.js:106:9)
at Function.get (node_modules/httpplease/lib/index.js:139:16)
at InlineSVG.getFile (node_modules/react-inlinesvg/lib/index.js:151:14)
at InlineSVG.load (node_modules/react-inlinesvg/lib/index.js:193:19)
at callCallback (node_modules/react-dom/cjs/react-dom.development.js:10764:12)
at commitUpdateQueue (node_modules/react-dom/cjs/react-dom.development.js:10797:7)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:14264:11)
at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:15342:7)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
渲染SVG图标时。我的mock在package.json中配置为"\\.(svg|ttf|jpg)$": "<rootDir>/src/__mocks__/fileMock.js", and
fileMock.js`的内容是:
module.exports = 'test-file-mock';
`
答案 0 :(得分:0)
test-file-mock
是与所需模式不匹配的字符串。用空字符串替换它,即:
module.exports = '';