【发布时间】:2020-08-13 20:24:31
【问题描述】:
我在我的 React 16.13.0 应用程序中使用 jest 4.2.4。我已经设置了这种类型的模拟...
jest.spyOn(ReduxFirebase, "getFirebase").mockReturnValue({
firestore: jest.fn(() => ({ collection: jest.fn(() => collection) })),
});
如何在测试之间清除这个?我试过这个...
describe("User", () => {
afterEach(() => {
jest.clearAllMocks();
});
但它不起作用。稍后在测试套件中进行设置
jest.spyOn(ReduxFirebase, "getFirebase").mockReturnValue({
firestore: jest.fn(() => ({ collection: jest.fn(() => collection2) })),
});
不带(原来的间谍还在。
【问题讨论】:
-
问题不够具体。你怎么知道它不起作用?你期望什么,你会得到什么?
标签: reactjs mocking jestjs spy