- Core Features
- Nock enables testing HTTP requests in isolation for Node.js modules
- Works by overriding Node's http.request and http.ClientRequest functions
- Supports all HTTP verbs and supports both HTTP and HTTPS
- Allows intercepting requests with custom headers and body content
- Request Configuration
- Supports specifying hostname, path, body, and query string
- Handles request headers and replies with custom headers
- Includes automatic Content-Length and Date header generation
- Enables request body filtering and conditional matching
- Advanced Capabilities
- Provides request and response delay simulation
- Supports request headers and optional requests
- Enables recording and playback of HTTP calls
- Offers fixture recording and playback with nockBack
- Management
- Allows enabling/disabling real HTTP requests
- Provides scope filtering and conditional scope selection
- Includes cleanup and persistence options for interceptors
- Supports debugging through logging and environment variables