{"id":15664783,"url":"https://github.com/jaydenseric/snapshot-assertion","last_synced_at":"2025-05-05T23:54:07.048Z","repository":{"id":57364638,"uuid":"232319687","full_name":"jaydenseric/snapshot-assertion","owner":"jaydenseric","description":"Asserts a string matches a snapshot saved in a file. An environment variable can be used to save rather than assert snapshots.","archived":false,"fork":false,"pushed_at":"2023-04-25T22:05:24.000Z","size":62,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T23:54:01.375Z","etag":null,"topics":["esm","maintained","mjs","node","npm","typescript"],"latest_commit_sha":null,"homepage":"https://npm.im/snapshot-assertion","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/jaydenseric.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":".github/funding.yml","license":"license.md","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":"jaydenseric"}},"created_at":"2020-01-07T12:26:26.000Z","updated_at":"2025-01-03T13:48:12.000Z","dependencies_parsed_at":"2024-06-19T06:17:10.514Z","dependency_job_id":"75c6fe72-4702-4733-8bb2-4621724f0ab9","html_url":"https://github.com/jaydenseric/snapshot-assertion","commit_stats":{"total_commits":56,"total_committers":1,"mean_commits":56.0,"dds":0.0,"last_synced_commit":"4f81a7697f9685f929181c2e510d45b83645a7ee"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fsnapshot-assertion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fsnapshot-assertion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fsnapshot-assertion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fsnapshot-assertion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaydenseric","download_url":"https://codeload.github.com/jaydenseric/snapshot-assertion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596396,"owners_count":21773844,"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":["esm","maintained","mjs","node","npm","typescript"],"created_at":"2024-10-03T13:44:09.137Z","updated_at":"2025-05-05T23:54:07.024Z","avatar_url":"https://github.com/jaydenseric.png","language":"JavaScript","readme":"# snapshot-assertion\n\nAsserts a string matches a snapshot saved in a file. An environment variable can be used to save rather than assert snapshots.\n\n## Installation\n\nTo install [`snapshot-assertion`](https://npm.im/snapshot-assertion) with [npm](https://npmjs.com/get-npm), run:\n\n```sh\nnpm install snapshot-assertion --save-dev\n```\n\nThen, import and use the function [`assertSnapshot`](./assertSnapshot.mjs).\n\n## Examples\n\nA snapshot assertion in a [`test-director`](https://npm.im/test-director) test:\n\n```js\nimport fetch from \"node-fetch\";\nimport assertSnapshot from \"snapshot-assertion\";\nimport TestDirector from \"test-director\";\n\nconst tests = new TestDirector();\n\ntests.add(\"Get a todo.\", async () =\u003e {\n  const response = await fetch(\"https://jsonplaceholder.typicode.com/todos/1\");\n  await assertSnapshot(await response.json(), \"snapshots/todo.json\");\n});\n\ntests.run();\n```\n\nUsing the `SAVE_SNAPSHOTS` environment variable to save snapshots when running a package script:\n\n```sh\nSAVE_SNAPSHOTS=1 npm run test\n```\n\n## Requirements\n\nSupported runtime environments:\n\n- [Node.js](https://nodejs.org) versions `^16.9.0 || \u003e= 18.0.0`.\n\nProjects must configure [TypeScript](https://typescriptlang.org) to use types from the ECMAScript modules that have a `// @ts-check` comment:\n\n- [`compilerOptions.allowJs`](https://typescriptlang.org/tsconfig#allowJs) should be `true`.\n- [`compilerOptions.maxNodeModuleJsDepth`](https://typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.\n- [`compilerOptions.module`](https://typescriptlang.org/tsconfig#module) should be `\"node16\"` or `\"nodenext\"`.\n\n## Exports\n\nThe [npm](https://npmjs.com) package [`snapshot-assertion`](https://npm.im/snapshot-assertion) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). These ECMAScript modules are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):\n\n- [`assertSnapshot.mjs`](./assertSnapshot.mjs)\n","funding_links":["https://github.com/sponsors/jaydenseric"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaydenseric%2Fsnapshot-assertion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaydenseric%2Fsnapshot-assertion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaydenseric%2Fsnapshot-assertion/lists"}