{"id":15416588,"url":"https://github.com/remcohaszing/jest-axios-snapshot","last_synced_at":"2025-04-19T14:33:27.526Z","repository":{"id":57280277,"uuid":"422874657","full_name":"remcohaszing/jest-axios-snapshot","owner":"remcohaszing","description":"Test axios HTTP responses using Jest snapshots","archived":false,"fork":false,"pushed_at":"2023-01-10T15:48:56.000Z","size":296,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-08T18:52:17.281Z","etag":null,"topics":["axios","jest","testing","vitest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remcohaszing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-30T12:27:34.000Z","updated_at":"2024-01-16T11:37:11.000Z","dependencies_parsed_at":"2023-02-08T19:15:15.235Z","dependency_job_id":null,"html_url":"https://github.com/remcohaszing/jest-axios-snapshot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fjest-axios-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fjest-axios-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fjest-axios-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fjest-axios-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remcohaszing","download_url":"https://codeload.github.com/remcohaszing/jest-axios-snapshot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234444584,"owners_count":18833657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","jest","testing","vitest"],"created_at":"2024-10-01T17:12:32.655Z","updated_at":"2025-01-17T23:52:15.934Z","avatar_url":"https://github.com/remcohaszing.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jest Axios Snapshot\n\n\u003e Test Axios responses using Jest snapshots\n\n[![build status](https://github.com/remcohaszing/jest-axios-snapshot/workflows/ci/badge.svg)](https://github.com/remcohaszing/jest-axios-snapshot/actions)\n[![codecov](https://codecov.io/gh/remcohaszing/jest-axios-snapshot/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/jest-axios-snapshot)\n[![npm](https://img.shields.io/npm/v/jest-axios-snapshot)](https://www.npmjs.com/package/jest-axios-snapshot)\n[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)\n[![jest](https://jestjs.io/img/jest-badge.svg)](https://jestjs.io)\n\n## Installation\n\n```sh\nnpm install jest-axios-snapshot\n```\n\n## Usage\n\nAdd the following to your Jest configuration:\n\n```json\n{\n  \"snapshotSerializers\": [\"jest-axios-snapshot\"]\n}\n```\n\nNow use an Axios response to match a Jest snapshot.\n\n```js\nimport axios from 'axios';\n\nit('should download example.com', async () =\u003e {\n  const response = await axios.get('https://example.com');\n  expect(response).toMatchSnapshot();\n});\n```\n\nThis was written with [axios-test-instance](https://github.com/remcohaszing/axios-test-instance) and\ninline snapshots in mind.\n\n```ts\nimport { request, setTestApp } from 'axios-test-instance';\n\nimport { app } from './app';\n\nbeforeAll(async () =\u003e {\n  await setTestApp(app);\n});\n\nit('should get data', async () =\u003e {\n  const response = await request.get('/');\n\n  expect(response).tpMatchInlineSnapshot(`\n    HTTP/1.1 200 OK\n    Connection: close\n    Content-Length: 17\n    Content-Type: application/json; charset=utf-8\n\n    {\n      \"hello\": \"world\"\n    }\n  `);\n});\n```\n\nBy default the `Date` header will be stripped. To set a custom response transformer, use\n`setResponseTransformer`\n\n```js\nimport { setResponseTransformer } from 'jest-axios-snapshot';\n\nsetResponseTransformer((response) =\u003e {\n  // Modify response\n  const { etag, ...headers } = response.headers;\n  return {\n    ...response,\n    headers,\n  };\n});\n```\n\n## See also\n\n- [axios-test-instance](https://github.com/remcohaszing/axios-test-instance) enables you to test a\n  Node.js server using axios.\n\n## License\n\n[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Fjest-axios-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremcohaszing%2Fjest-axios-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Fjest-axios-snapshot/lists"}