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

Popular posts from this blog

Android/Java: Crear un SplashScreen para nuestra aplicaciĆ³n

Android/Java: Video de fondo en nuestro Login