我想测试我的自定义钩子,但是在Resive18@ test -库/ for钩子库中没有工作,而是使用@test-库/for它有renderHook函数,而且工作正常,但是这个库没有用于异步钩子的waitForNextUpdate函数。因此,我无法测试我的自定义异步钩子。
发布于 2022-06-06 08:32:49
另一种可能是用waitFor
代替它。
在此之前:
await waitForNextUpdate();
expect(fetch).toHaveBeenCalledTimes(1)
之后
await waitFor(() => {
expect(fetch).toHaveBeenCalledTimes(1)
}
https://stackoverflow.com/questions/72308116
复制相似问题