DEV.co
Open-Source Testing · httptoolkit

mockttp

Mockttp is a TypeScript HTTP mock server and proxy library that lets you intercept, transform, and test HTTP requests in JavaScript and browser environments. It's commonly used for integration testing without stubbing code in-process, enabling accurate testing of real HTTP behavior across Node.js and browser contexts.

Source: GitHub — github.com/httptoolkit/mockttp
868
GitHub stars
107
Forks
TypeScript
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryhttptoolkit/mockttp
Ownerhttptoolkit
Primary languageTypeScript
LicenseApache-2.0 — OSI-approved
Stars868
Forks107
Open issues40
Latest releasev4.0.0 (2025-06-17)
Last updated2026-07-02
Sourcehttps://github.com/httptoolkit/mockttp

What mockttp is

Mockttp provides a promise-based, strongly-typed API for HTTP mocking and transparent proxying, supporting HTTPS with self-signed certificate generation, dynamic port allocation for parallel testing, and request/response inspection. It works as both a mock server (direct stubbing) and intercepting proxy, with support for Node.js subprocesses, browser tests, and remote devices.

Quickstart

Get the mockttp source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/httptoolkit/mockttp.gitcd mockttp# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Integration Testing with Real HTTP Requests

Test entire application stacks by intercepting genuine HTTP calls rather than stubbing at the JS level, allowing verification of real-world request/response behavior across node and browser environments using a single test suite.

Transparent HTTPS Proxying and Request Rewriting

Build scriptable HTTP proxies that capture, inspect, and rewrite HTTPS traffic with auto-generated certificates, useful for debugging, request transformation, and testing cross-process or remote device behavior.

Parallel Test Execution with Dynamic Configuration

Enable safe concurrent test runs with automatic port allocation and mock URL generation, avoiding port conflicts and simplifying test orchestration without manual port management.

Implementation considerations

  • Requires Node.js runtime for server; browser tests still need a running Mockttp instance (local or remote), adding infrastructure overhead to test environments.
  • HTTPS interception requires installing and trusting auto-generated certificates on the client side; setup varies by browser/OS and may require custom CA configuration.
  • Parallel test execution requires careful lifecycle management (start/stop per test or suite) to avoid port conflicts; dynamic port allocation mitigates but adds debugging complexity.
  • Request matching and response stubbing are synchronous at setup but async at assertion time; care needed to avoid race conditions or missing request captures in high-concurrency tests.
  • Full request/response introspection is powerful but can increase test verbosity; clear documentation of assertion patterns needed to keep tests maintainable.

When to avoid it — and what to weigh

  • Simple Stub-Based Unit Tests — If your testing needs are lightweight unit tests with in-process HTTP stubbing (e.g., using nock or msw for isolated component tests), Mockttp's full server overhead may be unnecessary complexity.
  • Non-JavaScript/TypeScript Environments — Mockttp is built for JS/TS ecosystems. If your primary testing infrastructure uses Java, Python, Go, or other languages without Node.js bridges, integration and maintenance will be awkward.
  • Production Traffic Mocking or Load Testing — Mockttp is designed for test automation and development; it is not intended for production traffic simulation, load testing, or high-throughput proxy scenarios where performance and stability at scale are critical.
  • Minimal Dependencies Constraint — If your project requires minimal external dependencies or has strict supply-chain constraints, Mockttp's transitive dependencies and maintenance surface should be reviewed.

License & commercial use

Apache License 2.0 (Apache-2.0) is a permissive OSI-approved open-source license that permits commercial use, modification, and redistribution with attribution and a copy of the license. No warranty is provided.

Apache 2.0 explicitly permits commercial use and modification. No proprietary license, royalties, or commercial restrictions apply. Verify compliance with your organization's OSS policy; attribution and license copy in distributions are required. No commercial support or indemnification provided by the licensor unless negotiated separately.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

Mockttp is designed for testing and development, not production. Self-signed certificate generation for HTTPS testing is appropriate for test environments. In CI/CD, ensure certificates are not trusted system-wide unless isolated to test runners. No public security audit data available; treat as a test-only tool. Verify that interception of HTTPS does not expose credentials or sensitive data in test logs.

Alternatives to consider

MSW (Mock Service Worker)

Browser-first, service-worker-based HTTP mocking with no server overhead; better for frontend unit/integration tests but less flexible for backend/proxy scenarios.

Nock

Lightweight, in-process HTTP request mocking for Node.js; simpler for unit tests but does not support browser or transparent proxying.

Wiremock

Language-agnostic, standalone HTTP mock server (Java-based); better for multi-language or microservice testing but heavier deployment and less JS/TS native integration.

Software development agency

Build on mockttp with DEV.co software developers

Evaluate Mockttp for your integration test suite. Start with the npm package and examples, then assess HTTPS setup and CI/CD integration needs for your environment.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

mockttp FAQ

Can I use Mockttp in both Node.js and browser tests with the same code?
Yes, Mockttp is designed as 'isomorphic' HTTP mocking; you write one test suite that works in both environments. Node.js tests run a local server; browser tests can use the same server instance or a remote one with proxy configuration.
Does Mockttp work with HTTPS?
Yes. Mockttp generates self-signed certificates on-the-fly and intercepts HTTPS traffic transparently. You must trust the certificate in your test client (browser CA, Node.js ca option, etc.), which is simple in test environments but requires care in CI/CD.
Can I run tests in parallel with Mockttp?
Yes, by design. Mockttp supports dynamic port allocation (call start() without a port argument), so multiple test processes can run concurrently without conflicts. Each instance gets its own port and mock configuration.
Is Mockttp suitable for load testing or production use?
No. Mockttp is optimized for test automation and development. For production traffic simulation or high-throughput proxying, use specialized tools like Wiremock, Nginx, or Envoy.

Work with a software development agency

DEV.co helps companies turn open-source tools like mockttp into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source testing stack.

Ready to improve your HTTP testing?

Evaluate Mockttp for your integration test suite. Start with the npm package and examples, then assess HTTPS setup and CI/CD integration needs for your environment.