ctimmerm/axios-mock-adapter

Axios adapter that allows to easily mock requests

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 40 minutes ago
Added to GitGenius on September 19th, 2026
Created on March 21st, 2016
Open Issues & Pull Requests: 96 (+0)
GitHub issues: Enabled
Number of forks: 251
Total Stargazers: 3,541 (+0)
Total Subscribers: 27 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 7.2 days
Mean response time: 261.4 days
90th percentile: 171.1 days
Tracked items: 12

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 12
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,027 days
Stale 30+ days: 12
Stale 90+ days: 12

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • test (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

axios-mock-adapter is a testing library that intercepts axios HTTP requests and returns mocked responses without making real network calls.

The tool solves the problem of testing code that depends on HTTP requests by replacing axios's default adapter with one that matches requests against registered mock handlers and returns predefined responses. Developers define mocks by chaining methods like onGet, onPost, or onAny to specify which requests to intercept, what conditions they must match (URL patterns, parameters, request bodies), and what responses to return. The adapter can simulate various scenarios including successful responses, network errors, timeouts, and redirects. Requests that do not match any handler are rejected with a 404 response by default, though this behavior can be customized. The tool also tracks request history, allowing tests to verify that expected calls were made.

The tool suits developers writing unit and integration tests for JavaScript applications that use axios. It works in both Node.js and browser environments with axios versions from 0.17.0 onward. The project is installed as a development dependency. Developers should choose this tool when they want to avoid making real network requests during testing and need fine-grained control over mock behavior. The README does not compare it to alternative mocking libraries.

The project maintains active engagement with pull requests and issues, addressing user-reported problems and feature requests. The codebase receives regular updates to support new axios versions and testing patterns. The maintainers have added features like asymmetric matchers for flexible request matching, Promise-based reply handlers for composing responses from multiple sources, and the onNoMatch configuration option for controlling default behavior. The tool includes comprehensive documentation with numerous examples covering common testing scenarios.