Control which stub wins when mock rules overlap
Make stub precedence explicit in WireMock, MSW and nock, and fail a test when a stub never answers, so a catch-all cannot hide the specific case you just added.
How-to › Section 10
Mocks, record-and-replay, contract and spec-driven tests, and layered SDK test suites, for APIs you ship and APIs you do not own.
16 guides in 3 topics. Every guide compares its approaches and shows the output its commands printed.
Standing in for the real API: Prism from an OpenAPI document, WireMock, MSW, nock, Mockoon, vendor sandboxes, record-and-replay (vcrpy, VCR, Polly.JS, go-vcr, responses, httptest), fault injection (Toxiproxy, chaos flags), and in-SDK mocks (the sdkgen test feature for an in-memory API and netsim for injected latency, 429s and outages as options).
Make stub precedence explicit in WireMock, MSW and nock, and fail a test when a stub never answers, so a catch-all cannot hide the specific case you just added.
Run one set of assertions about your code against a vendor SDK four ways, then bump the SDK a minor version and see which strategy noticed the change.
Describe routes, status codes, and delays in one Mockoon environment file, run it headless with the CLI, and point the screen you are building at it.
Build the client in test mode, seed it with records, and let the generated SDK answer its own calls from memory instead of reaching the network.
Wire the examples in your OpenAPI description to what the mock server returns, so the docs, the tests and the mock all show one payload.
Put Toxiproxy between a client and its dependency, slow, stall and cut the connection from the test, and prove each call fails at its time budget.
Intercept outbound requests in-process, assert on what your code sent as well as received, and turn off real network access so an unstubbed call fails.
Proving the implementation matches the description: Pact consumer-driven contracts (for an SDK consumer and for a vendor API you call), Schemathesis and Dredd property tests against a spec, Specmatic and Microcks, response validation middleware at runtime, and message contracts for service messages (seneca-msg-test as one option next to Pact message contracts).
Pick a contract style by what it fails on: the fields one consumer reads, or everything the published document describes, including the unused parts.
Write down the fields your integration reads, check a recorded response against them, and run the same check against the live API on a schedule.
Pin the body and the routing key of an event in a consumer contract, verify the publisher in CI, and see the three tools catch, or miss, a renamed topic.
Run the broker on Docker and Postgres, publish each pact under its commit and branch, and record deployments so the broker knows what runs where.
Keep one JSON example per documented response beside the document, run Specmatic in strict mode against the service, and fail the build when one is missing.
Make Dredd pass for reads and deletes that need a record first, without loosening an assertion, and fail loudly when a hook names a transaction that has gone.
Build a validator from the response schema in your OpenAPI document and run it over real responses, so a service that stops matching its description fails.
Layered SDK testing: unit tests per language, integration tests in a sandbox account, live suites with real credentials under rate limits, CI matrices across language versions, doc examples executed as tests, flaky-test policy.
Split an SDK suite into unit tests on an injected transport, integration tests against a sandbox, and a guarded live suite. Each layer gets a command and a trigger.
Create every record an integration suite needs under a run id, delete them newest first in a hook that runs on failure too, and sweep what earlier runs left.
Retries, timeouts, pagination and auth are the same problems in every client. Voxgig generates them from your OpenAPI description, in 23 languages, from one model.
Since 2018, Richard Rodger has talked with developer advocates, event organizers, and the people who build developer-facing companies about the specifics of the work.