explaingit

salmanm/nock

Analysis updated 2026-07-18 · repo last pushed 2020-01-08

JavaScriptAudience · developerComplexity · 2/5DormantSetup · easy

TLDR

Nock lets Node.js developers test code that makes HTTP requests by intercepting those calls and returning fake responses instead of hitting real servers.

Mindmap

mindmap
  root((repo))
    What it does
      Intercepts HTTP calls
      Returns fake responses
      No real network calls
    Tech stack
      JavaScript
      Node.js
    Use cases
      Test API integrations
      Simulate error responses
      Avoid rate limits
    Audience
      Node.js developers
      Test engineers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Test code that calls external APIs (GitHub, Amazon, weather services) without making real network requests.

USE CASE 2

Simulate error responses like a 500 status to test how your code handles failures.

USE CASE 3

Run tests reliably without depending on internet access or third-party service uptime.

USE CASE 4

Verify that your code called the expected endpoints with the right parameters.

What is it built with?

JavaScriptNode.js

How does it compare?

salmanm/nock3rd-eden/ircb.ioa15n/a15n
LanguageJavaScriptJavaScriptJavaScript
Last pushed2020-01-082016-11-162019-04-07
MaintenanceDormantDormantDormant
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Copy-paste prompts

Prompt 1
Show me how to use nock to mock a GET request to an external API in my Node.js test.
Prompt 2
Write a nock test that simulates a 500 error response from an API my code calls.
Prompt 3
Use nock to verify my code sent the correct headers and query parameters in a request.
Prompt 4
Explain how nock intercepts Node's built-in HTTP system to fake responses.

Frequently asked questions

What is nock?

Nock lets Node.js developers test code that makes HTTP requests by intercepting those calls and returning fake responses instead of hitting real servers.

What language is nock written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js.

Is nock actively maintained?

Dormant — no commits in 2+ years (last push 2020-01-08).

How hard is nock to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is nock for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.