Jest SecurityError: localStorage is not available for opaque origins

前端 未结 12 747
礼貌的吻别
礼貌的吻别 2021-01-30 19:24

When I want to run my project with the command npm run test, I get the error below. What is causing this?

FAIL
● Test suite failed to run

SecurityE         


        
12条回答
  •  情书的邮戳
    2021-01-30 19:34

    If you are using jsdom, make sure you include url.

    Checkout jsdom repository simple options. https://github.com/jsdom/jsdom#simple-options

    const jsdom = require("jsdom");
    const { JSDOM } = jsdom;
    
    const dom = new JSDOM(`...`, { url: "https://example.org/" });
    

提交回复
热议问题