vue项目单元测试jest相关问题

1.通过vue-cli新创建的项目,执行npm run unit,报以下错误:

FAIL
● Test suite failed to run

SecurityError: localStorage is not available for opaque origins at Window.get localStorage [as localStorage] (node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
      at Array.forEach ()

解决方法:在jest.config.js配置文件里面添加verbose和testURL字段

module.exports = {

  verbose: true,

  testURL: 'http://localhost/',

  ......

}

 

你可能感兴趣的:(vue项目单元测试jest相关问题)