{"id":48212,"library":"jest-axios-snapshot","title":"Jest Axios Snapshot","description":"A Jest snapshot serializer for Axios HTTP responses, enabling snapshot testing of HTTP response bodies and headers. Version 1.0.1 is the current stable release, with TypeScript types included. It serializes Axios response objects into a readable HTTP format, stripping the Date header by default but allowing custom transformers via setResponseTransformer. Differentiator: integrates seamlessly with Jest snapshot testing for Axios responses, supporting inline snapshots and custom header filtering. Built for use with axios-test-instance for testing Express/Koa apps.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/remcohaszing/jest-axios-snapshot","tags":["javascript","axios","jest","jest-snapshot","snapshot","typescript"],"install":[{"cmd":"npm install jest-axios-snapshot","lang":"bash","label":"npm"},{"cmd":"yarn add jest-axios-snapshot","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-axios-snapshot","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CJS require works in Node >=12 but not recommended for TypeScript.","wrong":"const { setResponseTransformer } = require('jest-axios-snapshot')","symbol":"setResponseTransformer","correct":"import { setResponseTransformer } from 'jest-axios-snapshot'"},{"note":"Not imported directly; add to Jest config as a snapshotSerializer.","wrong":"import 'jest-axios-snapshot'","symbol":"jest-axios-snapshot (as serializer)","correct":"\"snapshotSerializers\": [\"jest-axios-snapshot\"]"},{"note":"No default export; use only as serializer or named import setResponseTransformer.","wrong":"","symbol":"default export or named","correct":"import jestAxiosSnapshot from 'jest-axios-snapshot'"}],"quickstart":{"code":"// jest.config.js\nmodule.exports = {\n  snapshotSerializers: ['jest-axios-snapshot']\n};\n\n// test file\nimport axios from 'axios';\n\nit('should fetch example.com', async () => {\n  const response = await axios.get('https://example.com');\n  expect(response).toMatchSnapshot();\n});","lang":"typescript","description":"Shows how to configure Jest to use the serializer and snapshot test an Axios response."},"warnings":[{"fix":"import { setResponseTransformer } from 'jest-axios-snapshot';\nsetResponseTransformer(response => response);","message":"The Date header is stripped by default; to include it, you must use setResponseTransformer to preserve it.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure you pass the entire Axios response object, not just response.data.","message":"The serializer only works with Axios response objects; other objects passed to expect(...).toMatchSnapshot() will not be serialized.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update Node.js to version 12 or higher.","message":"v1.0.0 dropped support for Node <12; earlier versions (pre-1.0) may have supported older Node.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':22 'allow':49 'app':82 'axio':2,9,34,62,76,84 'axios-test-inst':75 'bodi':18 'built':71 'current':25 'custom':50,68 'date':44 'default':47 'differenti':54 'enabl':12 'express/koa':81 'filter':70 'format':41 'header':20,45,69 'http':10,16,40 'includ':31 'inlin':65 'instanc':78 'integr':55 'javascript':83 'jest':1,5,58,85,87 'jest-snapshot':86 'object':36 'readabl':39 'releas':27 'respons':11,17,35,63 'seamless':56 'serial':7,33 'setresponsetransform':53 'snapshot':3,6,13,59,66,88,89 'stabl':26 'strip':42 'support':64 'test':14,60,77,80 'transform':51 'type':30 'typescript':29,90 'use':73 'version':21 'via':52","created_at":"2026-06-07T16:55:28.915914+00:00","updated_at":"2026-06-07T16:55:28.915914+00:00","problems":[{"fix":"Run npm install jest-axios-snapshot --save-dev and ensure it's listed in package.json.","cause":"The package is not installed or Jest cannot resolve it due to module resolution configuration.","error":"Cannot find module 'jest-axios-snapshot' from 'jest.config.js'"},{"fix":"Ensure the config has snapshotSerializers: ['jest-axios-snapshot'] (string).","cause":"The snapshotSerializers entry might not be a string or the module exports incorrectly.","error":"Invalid serializer: expected a string or object"},{"fix":"Add 'jest-axios-snapshot' to snapshotSerializers in Jest config.","cause":"Using toMatchInlineSnapshot without configuring the serializer in Jest config.","error":"TypeError: expect(...).toMatchInlineSnapshot is not a function"}],"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/remcohaszing/jest-axios-snapshot#readme","github":"https://github.com/remcohaszing/jest-axios-snapshot","docs":null,"changelog":null,"pypi":null,"npm":"jest-axios-snapshot","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}}