.toHaveReturned()

Also under the alias: .toReturn()

If you have a mock function, you can use .toHaveReturned to test that the mock function successfully returned (i.e., did not throw an error) at least one time. For example, let's say you have a mock drink that returns true. You can write:

  1. test('drinks returns', () => {
  2. const drink = jest.fn(() => true);
  3. drink();
  4. expect(drink).toHaveReturned();
  5. });