From 10e706f4a5414802cc8dad321a3ee63b71089e66 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Fri, 27 Jul 2018 13:45:30 +0000 Subject: [PATCH] Jest - fix "SecurityError: localStorage is not available for opaque origins" with jsDom 11.12, jest stars failing with 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 () Looks like jsdom is just trying to follow the browser behaviour more closely, and without `testURL` jest defaults to assuming "about:blank" --- jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.js b/jest.config.js index 2548253b702..a84d6975ca2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,7 @@ module.exports = { roots: ['app/javascript'], setupFiles: ['./config/jest.setup.js'], testRegex: '(/__tests__/.*|(\\.|_|/)(test|spec))\\.(jsx?|tsx?)$', + testURL: 'http://localhost', transform: { '^.+\\.jsx?$': 'babel-jest', '.(ts|tsx)': 'ts-jest'