npm test fail with jest

  • A+
Category:Languages

When I want to run my project with the command $npm run test . I get the error below. please guide me .

FAIL ● 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>) 

 


In case, if you are accessing your application with a http://localhost prefix, you need to update your jest configuration as,

  "jest": {     "verbose": true,     "testURL": "http://localhost/"   } 

In case you do not already have any jest configuration, just include the configuration in your package.json. For example:

{   "name": "...",   "description": "...",   ...   "jest": {     "verbose": true,     "testURL": "http://localhost/"   } } 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: