Jest how to assert that function is not called

Solution 1:

Just use not.

expect(mockFn).not.toHaveBeenCalled()

See the jest documentation

Solution 2:

not did not work for me, throwing a Invalid Chai property: toHaveBeenCalled

But using toHaveBeenCalledTimes with zero does the trick:

expect(mock).toHaveBeenCalledTimes(0)