Fork of axios-mock-adapter that merges support for mocking requests with specific URL path parameters. v1.20.0 is the current stable release, with periodic updates. Key differentiator: allows matching requests based on path parameters like /users/:id, which the original adapter lacks. Supports ESM and CJS, includes TypeScript definitions, works in Node and browser, compatible with axios >= 0.9.0. Ideal for unit and integration testing of axios-based HTTP calls.
npm install axios-mock-adapter-path-paramsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates mocking GET requests with query params and path params, using regex and reply function, then restoring mock.
Use a function in reply to handle partial parameter matching, or mock with regex.
Call mock.restore() in afterEach or test teardown.
Use mock.reset() in setup/teardown to avoid test pollution.
Install @types/axios if not already present in your project.
Ensure axios >=0.9.0, but test with your specific version. If issues, pin to compatible versions.
Ensure the request URL/method matches exactly, or add a fallback handler with .onAny().reply()
Use 'import MockAdapter from ...' or 'const MockAdapter = require(...)'
Add a matching handler or use .onAny().reply() to catch all requests.