gpt4 book ai didi

reactjs - Jest 测试失败 SyntaxError,意外的 token 导出

转载 作者:行者123 更新时间:2023-12-05 05:35:23 27 4
gpt4 key购买 nike

由于从 swiper 包导入的代码,我的测试失败并出现错误 Unexpected token 'export',我在配置中将 node_modules 添加到 transformIgnorePatterns,但事实并非如此在职的。配置如下:

"jest": {
"watchPathIgnorePatterns": [
"node_modules",
".jest-test-results.json"
],
"transformIgnorePatterns": [
"node_modules"
],
"moduleNameMapper": {
"\\.(css)$": "<rootDir>/test/jest/__mocks__/styleMock.js",
"<rootDir>/node_modules/swiper/core/core.js": "<rootDir>/test/jest/__mocks__/styleMock.js"
}
}

enter image description here

最佳答案

问题是我没有在 trasnformIgnorePatterns 中指定包。以下作品:

"transformIgnorePatterns": [
"/node_modules/(?!(swiper|ssr-window|dom7))"
],

关于reactjs - Jest 测试失败 SyntaxError,意外的 token 导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73531988/

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