xhr-mock is a library for mocking the XMLHttpRequest object in JavaScript environments. It simplifies testing code that relies on XMLHttpRequest calls, enabling developers to define mock responses for specific URLs and HTTP methods. This allows for isolating dependencies and creating repeatable, predictable testing environments without making real network requests. It's commonly used in unit and integration tests for front-end applications and Node.js modules.
The npm package xhr-mock had frequent releases from August 2015 to July 2019, with periods of intense activity followed by lulls. The most releases occurred in August 2015 (6 versions) and January 2018 (4 versions). Since November 2019, there have been no new versions published.
Xhr-mock downloads saw consistent growth from March 2024 to July 2025, peaking above 1 million. August 2025 experienced a substantial drop to ~594k, and September 2025 (partial data) shows a further decrease to ~196k, suggesting a potential shift in usage or alternative solutions being adopted.