{"repo":"mswjs/interceptors","free":true,"listed":false,"github":"https://github.com/mswjs/interceptors","clone":"git clone https://github.com/mswjs/interceptors.git","description":"Low-level network interception library for Node.js.","language":"TypeScript","stars":679,"topics":["node","http","https","xhr","request","mock","intercept","interceptor","nodejs","request-interception"],"license":"MIT","category":"dev-tools","readme_excerpt":"@mswjs/interceptors Low-level network interception library for Node.js. Use this library if you wish to intercept any of the below: - Raw TCP and TLS socket connections ( net.connect() , tls.connect() ); - HTTP requests regardless of the request client (e.g. http.request() , axios() , etc); - Fetch requests (both global fetch() and custom fetch implementations like undici() ); - WebSocket connections (global WebSocket constructor). Motivation There has been a few attempts at the network interception in Node.js throughout its existence. Around 2018, those efforts have settled on patching http.request() and http.ClientRequest , if not resorting to far worse practices like patching request clients directly. These algorithms turned network requests into black boxes that, effectively, short-circuited the network code at the interception point. Consider how Node.js orchestrates an average HTTP request: You can see how intercepting requests at the http.request() level (2) is rather limiting as, typically, nothing executes past the interception point. As a result, whenever such interception is introduced, it significantly deviates your system from how it normally behaves otherwise. So I decided to build a network interception algorithm that would have no such limitations, would execute as much of the Node.js network code as possible, and actually establish network connections (yes, even when mocking requests to non-existing hosts). On top of that, I want that algorithm to be fully av","default_branch":null,"files":null,"tree":[],"storefront":"/r/mswjs","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mswjs/interceptors/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}