【发布时间】:2019-07-31 23:27:46
【问题描述】:
我用 jest 为我的 API 编写了一个测试。我在测试文件中添加了一个调用我的 API 的函数,如下所示:
import AuthManager from "../Client/Modules/Auth/AuthManager";
并按如下方式使用:
test("login api resolves true", () => {
return expect(AuthManager.login("test", "test")).resolves.toMatchObject(
expect.objectContaining({
accessToken: expect.any(String),
email: expect.any(String),
expiresIn: expect.any(Number),
refreshToken: expect.any(String),
userFullName: expect.any(String),
userId: expect.any(Number)
})
);
});
我的测试通过了,但出现如下错误:
错误:未实现:window.alert
我该如何解决这个问题?
【问题讨论】:
标签: reactjs api unit-testing jestjs