.toBeDefined()

Use .toBeDefined to check that a variable is not undefined. For example, if you just want to check that a function fetchNewFlavorIdea() returns something, you can write:

  1. test('there is a new flavor idea', () => {
  2. expect(fetchNewFlavorIdea()).toBeDefined();
  3. });

You could write expect(fetchNewFlavorIdea()).not.toBe(undefined), but it's better practice to avoid referring to undefined directly in your code.