Skip to content

fix(unit-mocha): set url option for jsdom-global #3131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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