gpt4 book ai didi

reactjs - SecurityError : localStorage is not available for opaque origins with new testEnvironmentOptions. url 选项

转载 作者:行者123 更新时间:2023-12-05 02:28:59 25 4
gpt4 key购买 nike

我得到一个错误SecurityError: localStorage is not available for opaque origin。我尝试了所有关于这个问题的建议:

  • 设置testURL: "http://localhost/",
  • 设置 testEnvironmentOptions: { url: 'https://localhost/' }

所有这些都在 jest.config.js 中,但它对我不起作用。我的 jest.config.js 文件:

  modulePaths: ["<rootDir>/src"],
moduleNameMapper: {
"\\.(css|less|sass|scss)$": "identity-obj-proxy",
},
moduleDirectories: [
"node_modules",
],
setupFilesAfterEnv: ["mock-local-storage"],
testEnvironment: "jsdom",
verbose: true,
testURL: "http://localhost/",
};```

Help me please

最佳答案

这些链接的答案对我不起作用。这是唯一做的事情:https://jestjs.io/docs/upgrading-to-jest28#jsdom

npm i --save-dev jest-environment-jsdom

很好奇错误消息是如何排列的(它没有排列),但新的必需依赖项绝对是我这边的问题。

关于reactjs - SecurityError : localStorage is not available for opaque origins with new testEnvironmentOptions. url 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72392560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com