I am using JEST framework for unit testing for my node.js project. I Used mockImplementationOnce for mocking thirdParty library methods as follows: jest.mock('abc', () => { return { a: { b: jest.fn() } }; }); const abcjs= require('abc');
describe("1st test", () => {
test("should return true", async () => {
abcjs.a.b.mockImplementationOnce(() => Promise.resolve(
return true}
));
});
});
describe("2nd test", () => {
test("should return false", async () => {
abcjs.a.b.mockImplementationOnce(() => Promise.resolve(
return false}
));
});
});
1st test executed successfully , but 2nd test Its calling the actual method, its not mocking. I tried resetting mocks afterEach but it didn't help.