Nock: Detailed Overview & Metrics

v13.5.6(12 days ago)

This package is actively maintained.Types definitions are bundled with the npm packageNumber of direct dependencies: 3Monthly npm downloads

Nock is a powerful HTTP mocking and expectations library for Node.js. It allows you to simulate HTTP requests and responses, making it ideal for testing applications that make HTTP calls. With Nock, you can define custom HTTP endpoints, intercept outgoing requests, and mock responses to ensure consistent behavior during testing.

Compared to other mocking libraries like Sinon.js or Mockttp, Nock provides a more specialized and focused solution specifically tailored for HTTP mocking. Its ease of use and robust functionality make it a popular choice among developers for testing HTTP interactions in Node.js applications.

Alternatives:
axios-mock-adapter+
fetch-mock+
msw+
supertest+
jest-fetch-mock+
mockttp+
nise+
fetch-mock-jest+
http-server-mock+
node-mocks-http+

Tags: node.jshttpmockingtestingrequests