Test Doubles
General
// Definition
Umbrella term for any object that stands in for a real dependency in a test. Includes dummies, fakes, stubs, spies, and mocks — each with distinct semantics.
// Related terms
Mock
A test double that records how it was called and lets the test assert on those interactions. Pre-programmed with expectations about which methods will be called and how.
Stub
A test double that returns canned responses to method calls, replacing real behaviour without recording or asserting on calls.
Spy
A test double that wraps real behaviour and records calls, so the test can both let the real code run and inspect how it was used.
Learn more · Cypress with TypeScript
Chapter 4 · Lesson 2: Stubbing API Responses