Skip to content

Conversation

michaelkhabarov
Copy link
Contributor

Set url: 'http://localhost' option to jsdom-global. This fix SecurityError: localStorage is not available for opaque origins in mocha tests caused of jsdom (jsdom/jsdom#2304).

@haoqunjiang
Copy link
Member

Thanks!

@adambiggs
Copy link

Is there any workaround for this problem in the meantime when using mocha?

@michaelkhabarov
Copy link
Contributor Author

You can create a setup file and require it in test:unit script in package.json

mocha.setup.js:

require('jsdom-global')(undefined, { pretendToBeVisual: true, url: 'http://localhost' })

package.json:

"test:unit": "vue-cli-service test:unit --require ./mocha.setup.js"

@haoqunjiang haoqunjiang merged commit 8d81e51 into vuejs:dev Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants