Software Testing, Software Development, DevOps, Developer, Software Engineering.
inventoryService = { checkStock: () => Promise.resolve(true), }; test("spy test", async () => { const spy = jest.spyOn(inventoryService, "checkStock"); const isInStock = await inventoryCheck("item123", inventoryService); expect(spy).toHaveBeenCalledWith("item123"); expect(isInStock).toBe(true);