{"id":47058,"library":"axios-hooks-mock","title":"axios-hooks-mock","description":"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.","status":"maintenance","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/dkershner6/axios-hooks-mock","tags":["javascript","axios","axios-hooks","testing","mock","jest","typescript"],"install":[{"cmd":"npm install axios-hooks-mock","lang":"bash","label":"npm"},{"cmd":"yarn add axios-hooks-mock","lang":"bash","label":"yarn"},{"cmd":"pnpm add axios-hooks-mock","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for axios-hooks; required at runtime","package":"react","optional":false},{"reason":"peer dependency for axios-hooks; required at runtime","package":"axios","optional":false},{"reason":"peer dependency; the library mocks this package","package":"axios-hooks","optional":false}],"imports":[{"note":"Package exports a default class. CommonJS require works but TypeScript may treat it differently.","wrong":"const AxiosHooksMock = require('axios-hooks-mock');","symbol":"AxiosHooksMock","correct":"import AxiosHooksMock from 'axios-hooks-mock';"},{"note":"AxiosHooksMockItem is a named type export; often forgotten.","wrong":"import { AxiosHooksMockItem } from 'axios-hooks-mock';","symbol":"AxiosHooksMockItem","correct":"import AxiosHooksMock, { AxiosHooksMockItem } from 'axios-hooks-mock';"},{"note":"AxiosHooksTuple is a type, so use import type to avoid runtime issues.","wrong":"import { AxiosHooksTuple } from 'axios-hooks-mock';","symbol":"AxiosHooksTuple","correct":"import type { AxiosHooksTuple } from 'axios-hooks-mock';"}],"quickstart":{"code":"jest.mock('axios-hooks');\nimport AxiosHooksMock from 'axios-hooks-mock';\nimport { mocked } from 'ts-jest/utils';\nimport useAxios from 'axios-hooks';\n\nconst refetch = jest.fn();\nmocked(useAxios).mockImplementation(\n  new AxiosHooksMock()\n    .get('https://testapi.com', [\n      { data: { testData: 'theData' }, loading: false },\n      refetch\n    ])\n    .implement()\n);","lang":"typescript","description":"Shows how to mock a single GET request using the convenience method, with jest and ts-jest."},"warnings":[{"fix":"Add jest.mock('axios-hooks') at the top of your test file.","message":"Must call jest.mock('axios-hooks') before mocking. The library does not do this automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use mocked(useAxios).mockImplementation(...) instead of relying on the library to mock useAxios.","message":"Removed useAxios mock integration in v1.1.0; now requires manual mock of useAxios via jest.spyOn or similar.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Use .addImplementation({ url, method: 'GET' }, ...) instead.","message":"Convenience methods .get(), .post(), etc. are deprecated in v1.1.0 in favor of .addImplementation() with explicit method.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use import type { AxiosHooksTuple } from 'axios-hooks-mock';","message":"TypeScript users need to import AxiosHooksTuple as a type, not a value. Fails at runtime if used as value.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set a default implementation with .default() or provide complete set of implementations.","message":"If no implementation matches the request config, default implementation (if set) is used; otherwise returns undefined. This can cause confusing test failures.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.0':26 '16.9.0':76 '2.0.0':82 '2020':34 'addimplement':59 'allow':61 'api':39 'axio':2,12,44,77,80,84,86 'axios-hook':11,43,79,85 'axios-hooks-mock':1 'built':65 'cadenc':28 'call':46 'config':49 'conveni':54 'coverag':71 'current':23 'default':62 'depend':74 'differ':48 'differenti':35 'especi':16 'fallback':63 'fluent':38 'full':69 'get':57 'hook':3,13,19,45,81,87 'implement':64 'javascript':83 'jest':90 'last':31 'librari':6 'like':33,56 'low':30 'method':50,55 'mock':4,9,41,89 'multipl':18,42 'param':52 'peer':73 'provid':36 'react':75 'releas':27,32 'requir':72 'simplifi':8 'stabl':24 'support':53 'test':15,70,88 'togeth':22 'typescript':67,91 'url':51 'use':21 'version':25","created_at":"2026-06-07T16:49:33.837191+00:00","updated_at":"2026-06-07T16:49:33.837191+00:00","problems":[{"fix":"Use import AxiosHooksMock from 'axios-hooks-mock'; or const { default: AxiosHooksMock } = require('axios-hooks-mock');","cause":"CommonJS require returns the module object, not the default export directly.","error":"TypeError: axios_hooks_mock_1.default is not a constructor"},{"fix":"Install axios-hooks as a devDependency and add jest.mock('axios-hooks') to test.","cause":"Missing jest.mock('axios-hooks') or peer dependency not installed.","error":"Cannot find module 'axios-hooks' from 'test.js'"},{"fix":"Use import { mocked } from 'ts-jest'; (ts-jest v27+) or keep using 'ts-jest/utils' if on older version.","cause":"ts-jest/utils.mocked was renamed in ts-jest v27 to just 'mocked' from 'ts-jest'. Using older import path.","error":"TypeError: (0 , ts_jest_utils_1.mocked) is not a function"},{"fix":"Provide a default implementation with .default() or ensure all configs are matched.","cause":"No default implementation set and no matching implementation found, returning undefined.","error":"Property 'data' does not exist on type 'undefined'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dkershner6/axios-hooks-mock#readme","github":"https://github.com/dkershner6/axios-hooks-mock","docs":null,"changelog":null,"pypi":null,"npm":"axios-hooks-mock","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}