awesome-repositories.comCategoriesBlog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
nock avatar

nock/nock

0
View on GitHub↗
13,103 stars·757 forks·JavaScript·MIT·9 views

Nock

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, and headers, as well as the management of mock lifecycles. The tool provides outbound request control to block all outgoing traffic except for specifically allowed hostnames.

Features

  • Network Request Interceptors - Intercepts outgoing HTTP requests to redirect traffic to predefined mock responses instead of a live server.
  • HTTP Mocking - Intercepts outgoing HTTP requests in Node.js to return predefined responses, decoupling application logic from external servers.
  • Request Matching - Matches requests using hostnames, paths, verbs, or headers through strings and regular expressions.
  • Request Matchers - Evaluates a collection of defined mock patterns against every intercepted HTTP call to determine the response.
  • API Response Simulators - Defines return status codes and response bodies using strings, JSON, or callbacks to simulate API behavior.
  • HTTP Mocking Libraries - Provides a comprehensive library for intercepting outgoing HTTP requests and returning predefined responses in Node.js.
  • API Expectation Frameworks - Functions as a framework to verify that specific HTTP calls were made with correct parameters and headers.
  • API Integration Testing - Enables verification that an application sends correct HTTP requests and handles various server responses within automated suites.
  • HTTP Interaction Recording - Captures real HTTP interactions as fixtures to replay them for deterministic offline testing.
  • Mock Interaction Recorders - Captures real network interactions as fixtures to be replayed in future test runs.
  • API Request Mocking - Intercepts network requests to simulate server responses and decouple code from external dependencies.
  • HTTP Interaction Recorders - Captures real network interactions as fixtures that can be replayed in future test environments.
  • Request Interception and Blocking - Captures outgoing calls to specific hosts and paths to return predefined responses instead of contacting live servers.
  • HTTP Request Interceptors - Captures outgoing network traffic to specific hosts and paths to prevent calls to live external servers.
  • Network Access Control - Blocks all outgoing HTTP requests to non-mocked hosts or allows specific hostnames to bypass the interceptor.
  • Outbound Network Blockers - Blocks all outgoing network traffic except for specifically allowed hostnames to prevent accidental external API calls during tests.
  • Error Simulation Utilities - Introduces artificial latency and triggers network errors to test how the application handles failures.
  • Dynamic Response Callbacks - Provides the ability to use JavaScript functions to generate dynamic, request-aware mock responses.
  • Mock State Resetting - Provides utilities for removing specific interceptors or clearing all active mocks to reset the test environment.
  • Request Verification - Inspects properties of outgoing requests to ensure they meet expected parameters and specifications.
  • Network Connectivity Controls - Restrict connections to specific hostnames to prevent accidental external network requests during testing.
  • Network Outbound Blocklists - Prevents accidental external network calls by blocking all outgoing traffic that does not match a mock.
  • Network Resilience Simulators - Introduces artificial latency and triggers network errors to verify application timeout and failure handling.
  • Response Simulators - Returns custom status codes and headers with timing delays to mimic various server response behaviors.
  • Lifecycle Management - Clears interceptors and restores original network behavior to reset the environment between test scenarios.
  • State Expectation Validation - Maintains a queue of pending requests to verify that specific API calls were made before tests complete.
  • Testing Frameworks - HTTP server mocking and request expectations.

Star history

Star history chart for nock/nockStar history chart for nock/nock

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Frequently asked questions

What does nock/nock do?

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.

What are the main features of nock/nock?

The main features of nock/nock are: Network Request Interceptors, HTTP Mocking, Request Matching, Request Matchers, API Response Simulators, HTTP Mocking Libraries, API Expectation Frameworks, API Integration Testing.

What are some open-source alternatives to nock/nock?

Open-source alternatives to nock/nock include: pgte/nock — Nock is a Node.js HTTP mocking library used to intercept outgoing network requests and return predefined responses. It… alisoftware/ohhttpstubs — OHHTTPStubs is an HTTP network mocking library and request interceptor used to simulate server responses for testing… getsentry/responses — Responses is a Python mocking library designed to intercept outgoing HTTP calls made with the Requests library to… bblimke/webmock — WebMock is a Ruby library for HTTP request stubbing, response simulation, and network interception. It serves as a… netflix/pollyjs — Pollyjs is an HTTP mocking and recording library designed to capture and replay network interactions to create… wheresrhys/fetch-mock — Fetch-mock is a testing utility designed to isolate application code from external network dependencies by…

Open-source alternatives to Nock

Similar open-source projects, ranked by how many features they share with Nock.
  • pgte/nockpgte avatar

    pgte/nock

    13,108View on GitHub↗

    Nock is a Node.js HTTP mocking library used to intercept outgoing network requests and return predefined responses. It functions as a network request interceptor and HTTP mock server, allowing developers to simulate external API behavior for automated testing without making live network calls. The project includes an API fixture recorder to capture real network interactions and save them as reusable data files for playback. It also features a network latency simulator that introduces artificial delays to outgoing HTTP responses to verify timeout handling and race conditions. The library prov

    JavaScript
    View on GitHub↗13,108
  • alisoftware/ohhttpstubsAliSoftware avatar

    AliSoftware/OHHTTPStubs

    5,068View on GitHub↗

    OHHTTPStubs is an HTTP network mocking library and request interceptor used to simulate server responses for testing application behavior without a live backend. It functions as a network request stubbing tool that captures outgoing network calls and replaces them with predefined mock data, custom status codes, and headers. The library distinguishes itself through its ability to simulate a wide range of network conditions, including artificial latency and connection failures. It supports dynamic response sequencing, allowing the tool to return a series of different responses for the same requ

    Objective-Ciosmockmock-server
    View on GitHub↗5,068
  • getsentry/responsesgetsentry avatar

    getsentry/responses

    4,350View on GitHub↗

    Responses is a Python mocking library designed to intercept outgoing HTTP calls made with the Requests library to return predefined simulated responses. It functions as a request verification framework and a network simulation tool, allowing for the verification of application behavior against various API response patterns without making real network calls. The project distinguishes itself through a traffic recorder that captures real network interactions and saves them to files for deterministic replay. It further enables the simulation of complex network scenarios, including the triggering

    Pythontag-production
    View on GitHub↗4,350
  • bblimke/webmockbblimke avatar

    bblimke/webmock

    4,050View on GitHub↗

    WebMock is a Ruby library for HTTP request stubbing, response simulation, and network interception. It serves as a test assertion framework for verifying outgoing HTTP traffic and a network interception layer that blocks external connections to prevent accidental requests during testing. The project provides capabilities for dynamic response generation and the sequencing of different return values for repeated requests to the same endpoint. It supports simulating network failures, such as timeouts or exceptions, and allows for response replays using raw HTTP data loaded from local files. The

    Ruby
    View on GitHub↗4,050
See all 30 alternatives to Nock→