Open-source tools for intercepting and stubbing network requests to facilitate reliable unit and integration testing.
nock is a Node.js HTTP mocking library and request interceptor. It captures outgoing network traffic to specific hosts and paths, returning predefined responses to decouple applications from external servers during automated testing. The project functions as an API expectation framework to verify that specific calls were made with correct parameters. It includes a traffic recorder that captures real network interactions as fixtures for playback and a network simulation tool to introduce artificial latency or trigger network errors. Its capabilities cover request matching via hostnames, paths
Nock is a comprehensive HTTP mocking and interception library for Node.js that provides robust request matching, response simulation, and traffic recording capabilities, making it a standard tool for testing network-dependent code.
Pollyjs is an HTTP mocking and recording library designed to capture and replay network interactions to create deterministic tests. It functions as a request interceptor and stubbing framework that records real API responses into files, ensuring consistent test results across different environments without relying on live network servers. The tool utilizes pluggable network adapters to support various environments and employs a state-based mode switching system to toggle between recording, replaying, and stubbing behaviors. It uses pattern-based request matching and persistent interaction sto
Polly.js is a comprehensive HTTP mocking and recording library that provides request interception, matching, and response simulation, making it a perfect fit for deterministic testing across both browser and Node.js environments.
MSW is a JavaScript API mocking library and integration testing tool designed to intercept network requests at the network level. It allows for the definition of mock data and status codes using routing syntax to simulate server responses without requiring changes to the application source code. The project utilizes a service worker to proxy API calls in the browser, providing a mechanism for isolated frontend development and testing. It employs platform-specific network adapters to maintain a consistent mocking interface across both browser and Node.js environments. The library covers a ran
MSW is a comprehensive HTTP mocking library that intercepts requests at the network level in both browser and Node.js environments, providing robust request matching and response simulation for integration testing.
WireMock is a suite of tools for service virtualization, providing mock servers for HTTP APIs and WebSocket communication. It serves as an HTTP API mock server and request verifier, allowing for the simulation of responses and the interception of network requests to test client applications without a live backend. The project differentiates itself through a service virtualization model that records real network traffic and replays it as stubs to mimic external service behavior. It includes a network fault injector to simulate response delays and connectivity issues, and a stateful scenario ma
WireMock is a comprehensive service virtualization tool that provides robust HTTP request interception, response stubbing, and traffic recording, making it a flagship solution for testing against mocked APIs.
VCR is a Ruby library that records and replays HTTP interactions during test runs, storing them in serialized cassette files. It captures real HTTP requests and responses, then serves those recorded responses instead of making actual network calls, enabling fast and deterministic test suites that work offline. The library provides configurable request matching, allowing comparisons based on method, URI, host, path, body, or headers to find the correct recorded response. It supports scheduled cassette re-recording to automatically refresh stored interactions at a configurable interval, keeping
VCR is a comprehensive Ruby library that provides request interception, matching, and response simulation through its record-and-replay cassette system, making it a flagship tool for testing HTTP interactions.
Mockoon is an HTTP API simulation platform and design tool used to create fake API endpoints that simulate server responses without a backend. It functions as an OpenAPI mock server tool and a JSON API mocking utility, allowing for the rapid iteration of API contracts and the generation of response templates. The project distinguishes itself through a combination of stateful mocking, using a local JSON database to simulate CRUD operations, and the ability to run as a headless API mock server via a command line interface. It supports real-time collaborative editing and AI-assisted prototyping
Mockoon is a standalone API simulation platform that provides robust request interception, response simulation, and traffic recording, making it a powerful tool for testing even though it functions as a server application rather than a code-level library.
Karate is an end-to-end testing framework and API test automation tool used to validate REST and SOAP APIs, drive browser interactions, and measure system performance. It functions as a unified solution for executing automated tests across both API backends and web frontends. The framework utilizes a custom domain specific language and Gherkin-style feature mapping to define requests and assertions. It includes an API mocking server to simulate backend responses, enabling development and integration testing without live dependencies. The tool covers a broad range of functional testing catego
Karate is a comprehensive API testing framework that includes a built-in mocking server capable of intercepting and simulating HTTP responses, making it a robust tool for your testing requirements.
Moya is a network abstraction layer for Swift that provides a structured framework for defining and executing REST API requests. It functions as a type-safe API client that decouples network endpoint definitions from the underlying implementation details to prevent configuration errors and URL typos. The project distinguishes itself by using protocol-based endpoint definitions and a provider-coordinated execution model. It includes a system for mapping network responses to strongly typed objects and features a dedicated tool for generating type-safe network interface files from external REST
Moya is a network abstraction layer for Swift that includes built-in utilities for stubbing and mocking API responses, making it a suitable tool for intercepting and simulating network requests during testing.
This project is a comprehensive Python network request framework designed for both synchronous and asynchronous HTTP communication. It provides a high-performance client capable of executing non-blocking requests within event-driven applications, while also supporting standard blocking calls for simpler scripts. The library is built to operate natively across diverse asynchronous runtimes, automatically detecting and utilizing the underlying event loop for concurrency. What distinguishes this library is its modular architecture, which decouples request construction from network execution thro
This is a full-featured HTTP client library that includes built-in utilities for response mocking and traffic recording, making it a capable tool for intercepting and simulating network requests during testing.
Typhoeus is a Ruby wrapper for libcurl that functions as a session-based HTTP client. It provides an interface for making both synchronous and asynchronous network requests. The project acts as a parallel request manager, using a managed queue to execute multiple network requests concurrently. It further distinguishes itself as a mocking tool for stubbing requests with predefined responses and as a caching layer that stores responses to avoid redundant network calls. The library covers a broad range of capabilities including session cookie management, response body streaming for large files,
Typhoeus is a Ruby HTTP client that includes built-in request stubbing and mocking capabilities, making it a suitable tool for intercepting and simulating network responses during your test suite.
Sinon is a JavaScript test double library and mocking framework used to isolate code and verify behavior during unit testing. It provides a collection of spies, stubs, and mocks that replace real function implementations and object methods with controlled substitutes. The project includes a specialized fake timer library for overriding the system clock, allowing the simulation of time progression to trigger timeouts and intervals without waiting for real-time delays. It also features a test sandbox mechanism to group multiple fakes together, ensuring the original state is restored between tes
Sinon is a comprehensive test double library that provides robust capabilities for intercepting and stubbing network requests alongside its broader suite of function and object mocking tools.