API Mocking
// Definition
Replacing a real API with a controlled stand-in that returns scripted responses. Lets you test client behaviour against edge cases (5xx, slow responses, malformed payloads) that the real API rarely produces on demand.
// 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.
Service Virtualisation
Simulating the behaviour of dependent services — including timing, errors, and stateful protocols — that aren't available, are too costly to call, or are still being built. Broader than API mocking: covers protocols beyond HTTP and stateful interactions.
Contract Testing
Verifying that two services agree on the shape of the messages they exchange. Catches breaking API changes without expensive end-to-end tests across multiple deployed services.
Learn more · Cypress with TypeScript
Chapter 4 · Lesson 2: Stubbing API Responses