How to reset a spy in Jasmine?

const spy = spyOn(somethingService, "doSomething");

spy.calls.reset();

This resets the already made calls to the spy. This way you can reuse the spy between tests. The other way would be to nest the tests in another describe() and put a beforeEach() in it too.

Leave a Comment