A lightweight library for stubbing axios HTTP requests and responses in tests, providing a developer-friendly API to define stubs via inline objects, JSON files, or JS modules. The current version (1.0.7-alpha.1) supports global axios stubbing and recording real calls for later replay. Key differentiators: zero-config setup, support for both request/response stubbing and recording, and TypeScript type definitions included. It is less mature than alternatives like axios-mock-adapter, but offers a simpler stubbing API ideal for quick test setup. Development appears slow with alpha releases indicating experimental status.
npm install axios-stubberNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: stubbing a GET request to return a predefined response, then verifying the mocked call.
Pin to exact version and test thoroughly before upgrading.
Always store the return value of axiosStubber and call restore() in afterEach/teardown.
Define stubs in the order you expect them to match, or use a single stub per request pattern.
Lock to a specific version (e.g., 1.0.7-alpha.1) and review changelog before upgrading.
Use ES module import: `import axiosStubber from 'axios-stubber';`
Ensure the stub request object has the same method and url as the axios call. Use exact strings.
Ensure stubs are registered before axios calls and restore after the test assertions.
No dependency data recorded yet.