Mock Server
Pronunciationmock SUR-ver
Definition
A mock server is a fake HTTP server that answers requests from the code under test with preset responses. Tests can call an API without reaching the real service.
Where you hear it
In API and integration tests, and in frontend work when the backend is not ready or a third-party service is slow, costly or rate-limited.
Examples
Our integration tests call a mock server instead of the real payment API.
A mock server returns canned responses for every HTTP call the app makes.
Start the mock server before the tests and stop it when they finish.
Common mistake
Treating the mock server as the real API. It answers only what you configured, so a test can pass while the real service behaves differently.
Don't confuse with
A test double replaces an object or function inside the test. A mock server replaces a remote service over the network, so the real HTTP client code still runs and the network call itself is tested.
Say it at work
- In a meeting or chat
Point the tests at the mock server, not the live API.
- In an email or ticket
Did we reset the mock server between test runs?
Keep exploring
More in Testing & Quality