小编vid*_*sha的帖子

React jest 和 MSAL 获取 BrowserAuthError :加密

我正在尝试测试一些使用 MSAL 进行身份验证的组件。

到目前为止,我有一个简单的测试,测试我的组件是否可以渲染,如下所示:

// <MsalInstanceSnippet>
const msalInstance = new PublicClientApplication({
  auth: {
    clientId: config.appId,
    redirectUri: config.redirectUri
  },
  cache: {
    cacheLocation: 'sessionStorage',
    storeAuthStateInCookie: true
  }
});
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,我收到以下错误:

 BrowserAuthError: crypto_nonexistent: The crypto object or function is not available. Detail:Browser crypto or msCrypto object not available.

      10 |
      11 | // <MsalInstanceSnippet>
    > 12 | const msalInstance = new PublicClientApplication({
         |                      ^
      13 |   auth: {
      14 |     clientId: config.appId,
      15 |     redirectUri: config.redirectUri

      at BrowserAuthError.AuthError [as constructor] (node_modules/@azure/msal-common/dist/error/AuthError.js:27:24)
      at new BrowserAuthError …
Run Code Online (Sandbox Code Playgroud)

java typescript reactjs jestjs package.json

8
推荐指数
1
解决办法
6279
查看次数

标签 统计

java ×1

jestjs ×1

package.json ×1

reactjs ×1

typescript ×1