jest-axios is a Jest testing utility (v0.2.1, last released in 2020) that simplifies mocking REST API requests made with Axios. It provides a declarative way to define reusable mock endpoints, internal data storage, and helpers for collections and models. Unlike manual Jest mock functions or libraries like msw (which intercepts at the network level), jest-axios overrides Axios specifically, making it lighter for Axios-heavy projects. However, it relies on Jest's automock feature for Axios, which can cause issues with imports. The package appears to be in maintenance mode with infrequent updates.
npm install jest-axiosNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a mock server with data and endpoints, then use it in a Jest test with Axios.
Call jest.mock('axios') at the top of your test file, before any imports that use axios.Ensure jest.mock('axios') is called before server.init(axios).Consider alternative like msw or jest-mock-axios for newer projects.
Add jest.mock('axios') at the top of your test file and ensure it is called before server.init(axios).Run 'npm install jest-axios --save-dev' or 'yarn add jest-axios --dev'.
Use named import: import { Server } from 'jest-axios'