Nock: Detailed Overview & Metrics

v13.5.4(2 months 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 code that interacts with external APIs or services. With Nock, you can define custom HTTP responses, intercept outgoing requests, and set up expectations for requests to ensure your code behaves as expected.

Compared to other mocking libraries like Sinon.js or Mockttp, Nock provides a more specialized and focused solution specifically tailored for HTTP mocking. It offers a simple and intuitive API for setting up mocks and assertions, making it a popular choice among developers for testing HTTP-dependent code.

Alternatives:
axios-mock-adapter+
sinon+
jest-mock+
miragejs+
msw+
fetch-mock+
pretender+
supertest+
node-mocks-http+
intercept-stdout+

Tags: node.jshttpmockingtestingapi