XHR Mocking Utility

JSON →
library 2.5.1 ·javascript
verified May 27, 2026

XHR-mock is a JavaScript utility designed for intercepting and mocking `XMLHttpRequest` objects, primarily for testing purposes or for front-end development against an unbuilt backend. It allows developers to define mock responses for specific HTTP methods and URLs, enabling reliable and isolated unit and integration tests for code that relies on browser-native `XMLHttpRequest` or libraries built upon it, such as Axios, jQuery, and Superagent. The current stable version is 2.5.1. The library is actively maintained with periodic updates and improvements, demonstrated by its progression through several minor and major versions since its initial release. A key differentiator is its ability to operate seamlessly in both Node.js environments (for server-side testing) and browser environments, while maintaining compliance with the WHATWG XHR specification. It offers a simple API for setting up global mocks and ensuring proper cleanup, which is crucial for preventing test pollution.

total hits 18
actors 6 distinct systems
last hit 1d ago MetaBot
GPTBot
5
MetaBot
4
ChatGPT-User
3
Script
1
Search engines
1

top countries 🇺🇸 United States · 🇨🇦 Canada · 🇩🇪 Germany · 🇫🇷 France