-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
JSDom 11.12 causes SecurityError: localStorage is not available for opaque origins #6766
Comments
Relevant: jsdom/jsdom#2304 |
Update: as noted in the linked issue, adding the following to the Jest config solves the issue:
Perhaps the default for this config option needs to be changed? |
This fix seems to work. However when i run my tests from Webstorm i always get empty test suite now. Looks like there are also issues now with the Jest plugin in Webstorm when adding a testURL. |
@csvan @SamuelBrucksch I was just debugging the issue. Jest is using a dependency module called |
Hmm. Defining |
As a temporary workaround you can install jsdom Cheers! |
Add "jest": {
"testEnvironment": "node"
}, |
A recent Renovate merged Jest update caused all tests to start to fail, due to JSDom security errors. This config adjustment was recommended in the Jest repo to address this issue. Relates to: jestjs/jest#6766 (comment)
Use the file path instead of file content to import schema. Set Jest's environment to node to avoid the error with jsdom's localStorage, see jestjs/jest#6766 and jsdom/jsdom#2304. BREAKING CHANGE: Use absolute path inside DSL won't work anymore, but now will be the same behavior of `graphql-import` dealing with paths. Fix prisma-labs#10
Jest updated the JSDOM dependency to 11.12+ in a recent update. This update causes Jest to throw a security error about localStorage when the tests are assumed to run in the browser and no `testURL` is defined. Since our tests are not run in the browser, a workaround for this issue is to explicitly define the environment as `node`. Hopefully this protects us from weird edge cases in the future. Refs: jestjs/jest#6766, jsdom/jsdom#2304
Jest updated the JSDOM dependency to 11.12+ in a recent update. This update causes Jest to throw a security error about localStorage when the tests are assumed to run in the browser and no `testURL` is defined. Since our tests are not run in the browser, a workaround for this issue is to explicitly define the environment as `node`. Hopefully this protects us from weird edge cases in the future. Refs: jestjs/jest#6766, jsdom/jsdom#2304
Jest updated the JSDOM dependency to 11.12+ in a recent update. This update causes Jest to throw a security error about localStorage when the tests are assumed to run in the browser and no `testURL` is defined. Since our tests are not run in the browser, a workaround for this issue is to explicitly define the environment as `node`. Hopefully this protects us from weird edge cases in the future. Refs: jestjs/jest#6766, jsdom/jsdom#2304
Jest updated the JSDOM dependency to 11.12+ in a recent update. This update causes Jest to throw a security error about localStorage when the tests are assumed to run in the browser and no `testURL` is defined. Since our tests are not run in the browser, a workaround for this issue is to explicitly define the environment as `node`. Hopefully this protects us from weird edge cases in the future. Refs: jestjs/jest#6766, jsdom/jsdom#2304
- Handle major changes to JSDom in 11.12 ([read here](jestjs/jest#6766)) - Setting test URL for jest environment to handle above ([read here](https://jestjs.io/docs/en/configuration#testurl-string))
- Handle major changes to JSDom in 11.12 ([read here](jestjs/jest#6766)) - Setting test URL for jest environment to handle above ([read here](https://jestjs.io/docs/en/configuration#testurl-string))
Background: Running Jest without the testUrl option results in the following error: "localStorage is not available for opaque origins" jestjs/jest#6766
could not run tests due to this error -- jestjs/jest#6766
Update in package.json is required to work around jestjs/jest#6766
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
A clear and concise description of what the bug is.
Jsdom just recently upgraded to version 11.12, which includes support for
window.localStorage
and other features. See https://github.com/jsdom/jsdom/blob/master/Changelog.md.A fresh yarn install deduces that Jest uses this latest version, but this causes all existing Jest test cases to fail with:
SecurityError: localStorage is not available for opaque origins
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Test case should pass.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: