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