【问题标题】:client side tests fail using jhipster 5.1.0客户端测试使用 jhipster 5.1.0 失败
【发布时间】:2019-01-09 13:18:18
【问题描述】:

我正在使用 jhipster 5.1.0,当我生成一个新的单体应用程序 [使用默认选项] 并运行 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.

这是一个错误还是我在本地遗漏了什么?

【问题讨论】:

标签: angular jhipster


【解决方案1】:

看起来像一个错误。

尝试在 src/test/javascript/jest.conf.js 的底部添加这个:

testEnvironment: "node",
testUrl: "http://localhost/"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 2019-07-21
    • 2019-10-08
    • 1970-01-01
    相关资源
    最近更新 更多