我正在使用jhipster 5.1.0,并且当我使用默认选项生成一个新的monolith应用程序并运行yarn test
时,它失败,并显示以下输出:
$ yarn test
yarn run v1.7.0
$ yarn run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js
$ tslint --project tsconfig.json -e 'node_modules/**'
No valid rules have been specified
FAIL src/test/javascript/spec/app/admin/health/health.component.spec.ts
● 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 (<anonymous>)
FAIL src/test/javascript/spec/app/shared/login/login.component.spec.ts
● 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 (<anonymous>)
FAIL src/test/javascript/spec/app/admin/audits/audits.component.spec.ts
● 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 (<anonymous>)
FAIL src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts
...
● 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 (<anonymous>)
FAIL src/test/javascript/spec/app/admin/audits/audits.service.spec.ts
● 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 (<anonymous>)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 16 failed, 16 total
Tests: 0 total
Snapshots: 0 total
Time: 2.353s
Ran all test suites.
error Command failed with exit code 1.
是错误还是我在本地缺少东西?
答案 0 :(得分:1)
好像是个错误。
尝试将其添加到src / test / javascript / jest.conf.js的底部:
testEnvironment: "node",
testUrl: "http://localhost/"