The Liar

Definition:

  • Testing asynchronous code becomes tricky as it is based on a future value that you might receive or might not.

Also Known As:

  • Evergreen Tests, Success Against All Odds

Code Example:

test('the data is peanut butter', () => {
  function callback(data) {
    expect(data).toBe('peanut butter');
  }

  fetchData(callback);
});

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring