使用jest配置单元测试的时候运行npm run test
得到报错信息
SecurityError: localStorage is not available for opaque origins
解决方法就是更改jest.config.js里面的testEnvironment的字段为node 就行了
module.exports = {
verbose: true,
testEnvironment: 'node'
};
package.json里面的scripts为
"test": "jest --config tests/jest.config.js",