我正在测试包含异步函数的代码。即使在测试不使用await的流时,测试也会失败。当我删除async/await (这是可能的,因为测试流不需要它)时,测试通过。 我已经构建了代码和测试的简化示例。(1)使用async/await的代码示例(尽管在我的测试流程中不需要这样做): import React from 'react'
export class Example extends React.Componen
在运行特定文件中的任何测试之前,我正在尝试运行一些异步函数。user = await new User(userObj).save(); // This is a mongoose document ...每当我在beforeAll函数中有什么内容时,我都会得到一个错误:
超时-异步回调没有在jest.setTimeout.Error指定的5000 ms超时内调用:超时-异步回调没有在jes
我试图为我的NestJS API编写一个单元测试,但是当我试图在我的服务类中模拟一个方法时,我会得到这个TypeError: Cannot read property 'then' of undefined你能解释一下我的密码出了什么问题吗?}); }it('should create a new user without error', async () => {
jestexpect(userRepository