jeudi 2 janvier 2020

Jest how to test if a mocked function is called

In my jest test I mock a service that i have made like this:

jest.mock("../../services/testService");

this works fine. Now I want to test if a mocked function was called how can is do this?

It tried to put the mock in a variable like this:

const fn = jest.mock("../../services/testService");

But when i do this i get errors because the test now refer to the real testservice and not the mocked one.

Can someone tell me how to test if a mocked function was called?

Aucun commentaire:

Enregistrer un commentaire