vendredi 5 avril 2019

Jest: how to restore to a previous mocked implementation (not the original)

I have a set of 3 tests, the first one has the base mocked implementation:

Team.query = jest.fn(() => ({
  findOne: () => {
    return {
      is_disabled: false,
    };
  },
}));

In the second test, I perform a Team.query.mockImplementationOnce with the above, but I change is_disabled to true.

In the third test, I want to restore it back to the jest.fn implementation above. Is this possible?

Aucun commentaire:

Enregistrer un commentaire