gpt4 book ai didi

javascript - 无法模拟用于 react-inlinesvg Jest 测试的图标

转载 作者:行者123 更新时间:2023-11-28 10:41:42 27 4
gpt4 key购买 nike

获取堆栈跟踪

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 图标时。我的模拟在 package.json 中配置为 "\\.(svg|ttf|jpg)$": "<rootDir>/src/__mocks__/fileMock.js", and fileMock.js`的内容是:

module.exports = 'test-file-mock';

`

最佳答案

test-file-mock 是与所需模式不匹配的字符串。将其替换为空字符串,即:

module.exports = '';

关于javascript - 无法模拟用于 react-inlinesvg Jest 测试的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50804548/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com