{"id":13769465,"url":"https://github.com/satya164/jest-file-snapshot","last_synced_at":"2026-03-09T02:32:15.947Z","repository":{"id":50209231,"uuid":"150905417","full_name":"satya164/jest-file-snapshot","owner":"satya164","description":"Jest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest","archived":false,"fork":false,"pushed_at":"2024-07-10T19:51:02.000Z","size":2396,"stargazers_count":43,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T01:12:24.573Z","etag":null,"topics":["hacktoberfest","jest","snapshot-testing","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satya164.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-29T21:44:37.000Z","updated_at":"2025-03-11T11:04:51.000Z","dependencies_parsed_at":"2024-07-10T23:09:52.244Z","dependency_job_id":null,"html_url":"https://github.com/satya164/jest-file-snapshot","commit_stats":{"total_commits":48,"total_committers":9,"mean_commits":5.333333333333333,"dds":"0.29166666666666663","last_synced_commit":"317ce87d1a6a635061c76b5d41ea7717eaa21636"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fjest-file-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fjest-file-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fjest-file-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fjest-file-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satya164","download_url":"https://codeload.github.com/satya164/jest-file-snapshot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137890,"owners_count":21053775,"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":["hacktoberfest","jest","snapshot-testing","testing"],"created_at":"2024-08-03T17:00:26.332Z","updated_at":"2026-03-09T02:32:15.893Z","avatar_url":"https://github.com/satya164.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Snapshot"],"readme":"# jest-file-snapshot\n\n[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![MIT License][license-badge]][license]\n[![Version][version-badge]][package]\n\nJest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest. Writing a snapshot to a separate file means you have proper syntax highlighting in the output file, and better readability without those pesky escape characters. It's also useful if you have binary content.\n\n## Installation\n\n```sh\nnpm install --save-dev jest-file-snapshot\n```\n\nor\n\n```sh\nyarn add --dev jest-file-snapshot\n```\n\n## Usage\n\nExtend Jest's `expect`:\n\n```js\nimport { toMatchFile } from 'jest-file-snapshot';\n\nexpect.extend({ toMatchFile });\n```\n\nThen use it in your tests:\n\n```js\nit('matches content of file on disk', () =\u003e {\n  expect(content).toMatchFile();\n});\n```\n\nThe content passed can be of type `string` or a `Buffer`. The comparison be done using `Buffer.equals()` instead of `===` if a `Buffer` is passed.\n\nThe matcher takes two optional arguments:\n\n- `filepath`: path to the file whose content should be matched, e.g. `expect(content).toMatchFile(path.join(__dirname, 'output.md'))`\n- `options`: additional options object for the matcher, with following properties:\n  - `diff`: options for [`jest-diff`](https://github.com/facebook/jest/tree/master/packages/jest-diff)\n  - `fileExtension`: optional file extension to use for the snapshot file.\n\nYou should also [exclude the output files from Jest's watcher](https://jestjs.io/docs/en/configuration#watchpathignorepatterns-arraystring) so that updating the snapshot doesn't re-run the tests again.\n\nFor example, by default `toMatchFile` uses a folder named `__file_snapshots__` which you can exclude by adding the following under the `jest` key in `package.json`:\n\n```json\n\"watchPathIgnorePatterns\": [\n  \"__file_snapshots__\"\n]\n```\n\n## Credits\n\n- [jest-image-snapshot](https://github.com/americanexpress/jest-image-snapshot)\n\n## Contributing\n\nMake sure your code passes the unit tests, ESLint and TypeScript. Run the following to verify:\n\n```sh\nyarn test\nyarn lint\nyarn typescript\n```\n\nTo fix formatting errors, run the following:\n\n```sh\nyarn lint -- --fix\n```\n\n\u003c!-- badges --\u003e\n\n[build-badge]: https://img.shields.io/circleci/project/github/satya164/jest-file-snapshot/main.svg?style=flat-square\n[build]: https://circleci.com/gh/satya164/jest-file-snapshot\n[coverage-badge]: https://img.shields.io/codecov/c/github/satya164/jest-file-snapshot.svg?style=flat-square\n[coverage]: https://codecov.io/github/satya164/jest-file-snapshot\n[license-badge]: https://img.shields.io/npm/l/jest-file-snapshot.svg?style=flat-square\n[license]: https://opensource.org/licenses/MIT\n[version-badge]: https://img.shields.io/npm/v/jest-file-snapshot.svg?style=flat-square\n[package]: https://www.npmjs.com/package/jest-file-snapshot\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatya164%2Fjest-file-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatya164%2Fjest-file-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatya164%2Fjest-file-snapshot/lists"}