How can I test that a function has not been called?

Solution 1:

Use the not operator:

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