vue-cli 单元测试报错 jest 报错(图文)

vue-cli 单元测试报错 jest 报错(图文),第1张

现象:

vue-cli创建的项目中,运行npm run unit报错,如图:

问题1: Option "mapCoverage" has been removed, as it's no longer necessary.

解决:此属性已移除,详细可以见 https://jestjs.io/docs/en/configuration 官方公布的属性,在test/unit/jest.conf.js找到并删除该属性

 找到 配置文件  并移除  该属性:

问题2:localStorage is not available for opaque origins

解决:在jest.config.js里:

 

新增红框处属性

jest : SecurityError: localStorage is not available for opaque origins · Issue #2304 · jsdom/jsdom · GitHubWhen I run a jest with my test cases. It shows the following error when I upgrade the package. In my test cases, there is no localStorage is used. How can I fix this problem? SecurityError: localStorage is not available for opaque origin...https://github.com/jsdom/jsdom/issues/2304 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/725082.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存