{"id":15693599,"url":"https://github.com/florianrappl/jest-fs-snapshot","last_synced_at":"2025-06-27T21:33:56.883Z","repository":{"id":39731922,"uuid":"139671102","full_name":"FlorianRappl/jest-fs-snapshot","owner":"FlorianRappl","description":"Jest matcher for filesystem snapshotting.","archived":false,"fork":false,"pushed_at":"2024-06-18T01:18:33.000Z","size":1096,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-03-28T15:51:47.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://npm.im/jest-fs-snapshot","language":"JavaScript","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/FlorianRappl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["FlorianRappl"],"custom":["https://www.paypal.me/FlorianRappl"]}},"created_at":"2018-07-04T05:11:57.000Z","updated_at":"2024-03-11T15:19:30.000Z","dependencies_parsed_at":"2024-06-19T06:15:44.964Z","dependency_job_id":"295a8160-270e-4e46-88c9-55046e790523","html_url":"https://github.com/FlorianRappl/jest-fs-snapshot","commit_stats":{"total_commits":37,"total_committers":6,"mean_commits":6.166666666666667,"dds":0.5945945945945945,"last_synced_commit":"a3a1a53d5598afbed32456d7832455030261cf8b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fjest-fs-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fjest-fs-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fjest-fs-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fjest-fs-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlorianRappl","download_url":"https://codeload.github.com/FlorianRappl/jest-fs-snapshot/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004492,"owners_count":21196880,"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":[],"created_at":"2024-10-03T18:46:18.321Z","updated_at":"2025-04-15T04:22:17.452Z","avatar_url":"https://github.com/FlorianRappl.png","language":"JavaScript","funding_links":["https://github.com/sponsors/FlorianRappl","https://www.paypal.me/FlorianRappl"],"categories":[],"sub_categories":[],"readme":"# jest-fs-snapshot · [![npm][1]][2] [![Build Status][3]][4]\n\n[Jest](https://jestjs.io) matcher for filesystem snapshotting.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [API](#api)\n  - [`toMatchFilesystemSnapshot`](#tomatchfilesystemsnapshot)\n- [Credits](#credits)\n\n## Installation\n\n```sh\nyarn add jest-fs-snapshot\n```\n\n## Getting Started\n\n1. Extend Jest's `expect`\n\n```js\nimport { toMatchFilesystemSnapshot } from 'jest-fs-snapshot';\n\nexpect.extend({ toMatchFilesystemSnapshot });\n```\n\n2. Use it in your tests!\n\n```js\ntest('if build directory matches snapshot', () =\u003e {\n  const pathToBuildDir = path.resolve(process.cwd(), '.build');\n  expect(pathToBuildDir).toMatchFilesystemSnapshot();\n});\n```\n\nThis will create a `__fs_snapshots__` folder next to your test file with a snapshot file. On next runs it will chech if\nthe snapshot against the source directory and with throw on mismatches.\n\n## API\n\n### .toMatchFilesystemSnapshot([pathToSnapshot, options])\n\n#### Arguments\n\n1. `pathToSnapshot` _(String)_: An optional full path to a snapshot file.\n2. `options` _(Object)_: An optional object with additional configurations.\n   1. `customCompare` _({check: Function, compare: Function}[])_: Any custom compare function will be applied only if\n      the check method returns true. If multiple checks return true, the first hit will be used.\n\n#### Example\n\n```js\nconst diff = require('jest-diff');\n\nconst snapshotOptions = {\n  customCompare: [\n    {\n      check: path =\u003e path.endsWith('package.json'),\n      compare: (actualBuffer, expectedBuffer) =\u003e {\n        const actual = JSON.parse(actualBuffer);\n        const expected = JSON.parse(expectedBuffer);\n\n        // we want to ignore the peerModules\n        delete actual.peerModules;\n        delete expected.peerModules;\n\n        return diff(actual, expected);\n      },\n    },\n    {\n      // test.js files will be ignored\n      check: path =\u003e path.endsWith('.test.js'),\n      compare: () =\u003e true,\n    },\n  ],\n};\n\ndescribe('...', () =\u003e {\n  it('...', () =\u003e {\n    /**\n     * ...\n     */\n    expect(pathToBuildDir).toMatchFilesystemSnapshot(undefined, snapshotOptions);\n  });\n});\n```\n\n## Credits\n\nMany files for `encodings` fixture have been taken from https://github.com/mbbill/fencview.\n\n---\n\n[1]: https://img.shields.io/npm/v/jest-fs-snapshot.svg\n[2]: https://npm.im/jest-fs-snapshot\n[3]: https://florianrappl.visualstudio.com/piral-cli-plugins/_apis/build/status/FlorianRappl.jest-fs-snapshot?branchName=master\n[4]: https://florianrappl.visualstudio.com/piral-cli-plugins/_build/latest?definitionId=29\u0026branchName=master\n\n## License\n\nThis package is released using the MIT license. For more information see the [license file](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianrappl%2Fjest-fs-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianrappl%2Fjest-fs-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianrappl%2Fjest-fs-snapshot/lists"}