check if the method is not called in jest 1

check if the method is not called in jest

expect(controller.bar).not.toHaveBeenCalled();

Here is what the above code is Doing:
1. We’re creating a new instance of the controller.
2. We’re calling the controller’s foo method.
3. We’re calling the controller’s bar method.
4. We’re checking to see if the controller’s foo method was called.
5. We’re checking to see if the controller’s bar method was called.

Similar Posts