Jest测试失败,有两个错误



这是我要运行的测试:

it('should return Notification Groups', (done) => {
fetchAppNotifications('123', 'abc').subscribe((response) => {
try {
expect(response).toEqual(MOCK_FETCH_APP_NOTIFICATIONS_RESPONSE);
done();
} catch (error) {
done.fail(error);
}
});
});

返回以下错误:

  1. Timeout -异步回调没有在指定的5000毫秒超时内被调用
  2. 期望调用至少一个断言,但没有收到。

这是正在测试的功能:

export function fetchAppNotifications(practiceId: string, clinicId: string): Observable<INotificationGroups> {
const start = format(startOfDay(new Date()), 'M/d/yyyy');
const end = format(endOfDay(new Date()), 'M/d/yyyy');
return GET<INotificationGroups>(Api.Portal, 'AppNotifications/Get', {
params: {
practiceId,
start,
end,
type: '0',
status: '0',
clinicId,
},
});
}

我试过谷歌这些错误,但我没有得到任何帮助。还有其他的测试,和这个测试一样,对于其他没有错误的函数运行的很好。我完全不知道是什么导致了这个,但在其他测试中没有。Using Jest 26.6.3

设置为异步调用fetchAppNotifications('123', 'abc').subscribe(async(response) =>{}

相关内容

最新更新