A library for simplifying mocking of axios-hooks in tests, especially when multiple hooks are used together. Current stable version: 1.1.0. Release cadence is low (last release likely 2020). Differentiator: provides a fluent API to mock multiple axios-hook calls with different configs (method, url, params), supports convenience methods like .get() and .addImplementation(), and allows default fallback implementations. Built in TypeScript with full test coverage. Requires peer dependencies: react >=16.9.0, axios, and axios-hooks >=2.0.0.
npm install axios-hooks-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to mock a single GET request using the convenience method, with jest and ts-jest.
Add jest.mock('axios-hooks') at the top of your test file.Use mocked(useAxios).mockImplementation(...) instead of relying on the library to mock useAxios.
Use .addImplementation({ url, method: 'GET' }, ...) instead.Use import type { AxiosHooksTuple } from 'axios-hooks-mock';Set a default implementation with .default() or provide complete set of implementations.
Use import AxiosHooksMock from 'axios-hooks-mock'; or const { default: AxiosHooksMock } = require('axios-hooks-mock');Install axios-hooks as a devDependency and add jest.mock('axios-hooks') to test.Use import { mocked } from 'ts-jest'; (ts-jest v27+) or keep using 'ts-jest/utils' if on older version.Provide a default implementation with .default() or ensure all configs are matched.