首页 > 解决方案 > 用 Jest 测试 OAuth

问题描述

我是开玩笑的新手。我创建了一个包装 Microsoft 身份验证库 (MSAL.js) 的 Vue 插件。我想用 Jest 对它进行单元测试。基本测试已启动并运行(是挂载在 Vue 实例上的插件方法等)。

我想测试对身份验证服务的实际调用。我遇到了没有浏览器的问题。

错误:未实现:window.open

这是我的测试代码。

it('should fail with a useful error when configuration or option settings are not set or are incorrect', () => {
    const azureAuthService = new AzureAuthService()
    const testException = () => {
      azureAuthService.login()
    }
    expect(testException).toThrow(TypeError)
})

有关如何实施此测试的任何建议

标签: oauthjestjs

解决方案


推荐阅读