runner
runner copied to clipboard
Question - How can I test the call of a method with toHaveBeenCalled()?
When I tried to run the test with toHaveBeenCalled, I got an error saying that the argument must be a mock or a spy. How can I create a spy to test a method call?
the test function is:
test('updates a product', async ({ expect }) => {
const updateData = { title: 'Updated Product' }
mockProductRepository.update = async () => true
const result = await productService.updateProduct(1, updateData)
expect(result).toEqual(true)
expect(mockProductRepository.update).toHaveBeenCalledWith(1, updateData)
})
te error is: