Solve SecurityError: localStorage is not available for opaque origins React Native
SecurityError: localStorage is not available for opaque origins
On React Native
Fix adding this to package.json
"jest": {
"preset": "react-native",
"setupFilesAfterEnv": [
"<rootDir>setup-test.js"
],
"verbose": true,
"testURL": "http://localhost/",
"testEnvironment": "node"
}
If it does not work, try it:
Change your setup-test.js jsdom like this:
/**
* Set up DOM in node.js environment for Enzyme to mount to
*/
const { JSDOM } = require('jsdom');
const url = 'http://localhost';
const jsdom = new JSDOM('<!doctype html><html><body></body></html>', { url });
Comments
Post a Comment