LANGUAGE/!$%!% ERROR NOTE
[Mocha] Uncaught SecurityError: localStorage is not available for opaque origins
forgiveall
2020. 3. 22. 12:39
NodeJS - Mocha
1. Error - 오류
Uncaught SecurityError: localStorage is not available for opaque origins
2. Problem - 문제
jsdom
11.12.0버전 부터 발생했다고 한다.
3. Solved - 해결
JSDOM 생성시 다음과 같이 url
속성에 http://localhost
값을 넣어서 사용한다.
jsdom
const dom = new JSDOM(``, { url: "http://localhost" });
mocha-jsdom
const dom = new JSDOM({ url: "http://localhost" });
4. Reference - 참조
- Mocha : SecurityError: localStorage is not available for opaque origins: https://github.com/jsdom/jsdom/issues/2383#issuecomment-442199291
- jest : SecurityError: localStorage is not available for opaque origins: https://github.com/jsdom/jsdom/issues/2304