vue-cli 3.0.0-rc.7 test fails

Created on 27 Jul 2018  ยท  4Comments  ยท  Source: vuejs/vue-cli

Version

3.0.0-rc.7

Node and OS info

npm 5.6.0 / node 8.11.3 / Ubuntu

Steps to reproduce

vue create hello-world (choose only unit test with jest)
cd hello-world/
npm run test:unit

What is expected?

Demo spec passes the test.

What is actually happening?

FAIL tests/unit/HelloWorld.spec.js
โ— 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>)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.465s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:unit: vue-cli-service test:unit
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Found this today, when my CI alarmed to me (there I use vue-cli 3.0.0-rc.3). In production we still use hardcode versions of packages in packege.json (for example "@vue/cli-service": "3.0.0-rc.3"), so, as I think, it may be reproduced in many previous releases

unit-jest upstream

Most helpful comment

Had the same problem after updating to 3.0.0-rc.7. Setting "testURL": "http://localhost/" in Jest config helped. Here's a related question from Stack Overflow: https://stackoverflow.com/questions/51554366/npm-test-fail-with-jest

All 4 comments

Had the same problem after updating to 3.0.0-rc.7. Setting "testURL": "http://localhost/" in Jest config helped. Here's a related question from Stack Overflow: https://stackoverflow.com/questions/51554366/npm-test-fail-with-jest

@epiphone thanks! This work!

If you are using jsdom, make sure you include url in jsdom configuration

const dom = new JSDOM(``, {
url: "https://example.org/",
});

Was this page helpful?
0 / 5 - 0 ratings