DevXTools
Mocking & Test Data

API Mocking Tools Compared

Mocking APIs and generating realistic test data are core to fast, reliable tests. This section covers every approach to fake an API or generate test data: HTTP interceptors, standalone mock servers, spec-driven mocking, record/replay tools, contract testing, and test data factories for JavaScript, TypeScript, and React Native.

HTTP interception libraries like MSW and Nock intercept requests at the network or module level, letting you mock responses inline without running a separate server. MSW works in browsers and Node.js via Service Workers; Nock patches Node's HTTP module and offers built-in record/replay. Choose MSW for full-stack apps; Nock for pure Node.js simplicity.

Mock servers such as WireMock, Mockoon, Mountebank, and JSON Server run standalone and return canned responses, useful when multiple services need to hit the same mock. Spec-first tools like Prism and Microcks generate mocks directly from OpenAPI or AsyncAPI specs, keeping mocks honest. Trade-off: standalone servers add infrastructure but enable cross-team reuse.

Record/replay tools like Polly.js, Hoverfly, Keploy, and Mockifyer (Node.js and React Native) capture real API traffic and replay it in tests, reducing manual setup — see when to record backend traffic as tests, and when to record fetch or axios in Node or React Native. Contract testing via Pact ensures consumer mocks match provider contracts. Test data generation tools like Faker, Chance, Fishery, and Mockaroo create realistic datasets. Pick based on whether you need simple random data (Faker/Chance), object factories (Fishery), or hosted generation (Mockaroo).

Find tools for your stack

Answer a few questions to find tools that match your needs.

Tools in this section

Top comparisons

Browse by category