Skip to content
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

Jest error - SecurityError: localStorage is not available for opaque origins #119

Closed
NileshParkhe83 opened this issue Jul 30, 2018 · 1 comment
Assignees

Comments

@NileshParkhe83
Copy link
Contributor

NileshParkhe83 commented Jul 30, 2018

Latest Jest version v23.4.2 produces below error for recipe from 'debugging-jest-tests/'.

 FAIL  test/subtract.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>)

It is because Jest assumes testEnvironment as JSDom by default.

Overriding default jest configuration in package.json fixes the error. (Tested on Node versions 8.5.0, 9.7.1 and 10.7.0 with Jest versions 20.0.4 and 23.4.2)

{
  //Other package.json entries
  "jest": {
    "testEnvironment": "node"
  }
}

Edit - First time Submitting a PR to fix this issue. Please review and guide me towards getting this PR accepted

NileshParkhe83 added a commit to NileshParkhe83/vscode-recipes that referenced this issue Jul 30, 2018
Pull request for Issue reported below:
Jest error - SecurityError: localStorage is not available for opaque origins microsoft#119
NileshParkhe83 added a commit to NileshParkhe83/vscode-recipes that referenced this issue Jul 30, 2018
Pull request for Jest error - SecurityError: localStorage is not available for opaque origins microsoft#119

Please excuse any inconvenience I may have caused as I this is only my first commit on github public repository.
auchenberg added a commit that referenced this issue Jul 30, 2018
Pull request for Jest issue - SecurityError: localStorage is not available for opaque origins #119
@NileshParkhe83
Copy link
Contributor Author

Thanks, I shall close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants