Nock: Detailed Overview & Metrics

v14.0.2(5 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 code that interacts with external APIs or services. With Nock, you can define custom HTTP endpoints, intercept requests, and set up detailed expectations for outgoing requests, enabling thorough testing of network-related functionality.

Compared to alternatives 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, making it easy to set up and manage mock HTTP interactions in your tests.

Alternatives:
axios-mock-adapter+
fetch-mock+
msw+
supertest+
jest-mock-axios+
mockyeah+
mockttp+
http-server-mock+
nise+
sinon+

Tags: node.jshttpmockingtestingexpectations