{"id":23626527,"url":"https://github.com/hyp3rflow/snap","last_synced_at":"2026-05-18T02:36:27.702Z","repository":{"id":43134863,"uuid":"470509365","full_name":"hyp3rflow/snap","owner":"hyp3rflow","description":"SNAPshot library for Deno.","archived":false,"fork":false,"pushed_at":"2022-03-17T09:25:55.000Z","size":23,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-09T15:14:06.176Z","etag":null,"topics":["deno","snapshot","test","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyp3rflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-16T09:16:25.000Z","updated_at":"2022-03-16T16:17:47.000Z","dependencies_parsed_at":"2022-09-03T07:24:03.342Z","dependency_job_id":null,"html_url":"https://github.com/hyp3rflow/snap","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hyp3rflow/snap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyp3rflow%2Fsnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyp3rflow%2Fsnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyp3rflow%2Fsnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyp3rflow%2Fsnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyp3rflow","download_url":"https://codeload.github.com/hyp3rflow/snap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyp3rflow%2Fsnap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33162690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["deno","snapshot","test","testing"],"created_at":"2024-12-27T22:55:29.588Z","updated_at":"2026-05-18T02:36:27.688Z","avatar_url":"https://github.com/hyp3rflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snap\n\n`Snap` is a test snapshot library for Deno. modified from [klick](https://github.com/sramam/klick).\n\n## Goal\n- Implement `assertSnapshot` on testing in [deno_std](https://github.com/denoland/deno_std)\n  - After accomplished, this repo will not be maintained.\n\n## Features\n\n- Two update modes:\n  1. `update` fine grained update (only filtered tests, even within a single\n     suite)\n  2. `refresh` coarse grained update (removes un-exercised snapshots within\n     suites)\n- Simple ability to `mask` variant fields, accessed via json-ptr\n- CI aware - does not update snapshots on CI server\n- Snapshot files are valid JSON5\n\n## Required Permissions\n\nIn practice, we'll need to use this:\n\n- `--allow-read`: to read snapshots\n- `--allow-write`: to create/update snapshots\n- `--unstable`: for `fs` capability from deno std-lib\n\nCurrent deno implementation does not allow for wild-cards and globs in the\npermissions `allow-list`. Ideally, this is the set of permissions `snap` needs:\n\n- `--allow-read=\"./**/*.assertSnapshot\"`: to read snapshots\n- `--allow-write=\"./**/*.assertSnapshot\"`: to create/update snapshots\n- `--unstable`: for `fs` capability from deno std-lib\n\n## Usage\n\n### Writing tests\n\n```\nimport test from \"https://deno.land/x/snap/mod.ts\";\n\ntest(`Simple test`, ({ assertSnapshot}) =\u003e {\n  const actual = {\n    a: 'a',\n    b: 1\n  }\n  assertSnapshot(actual);\n  actual.c = 'c'\n  assertSnapshot(actual);\n});\n\ntest(`Test with masks`, ({ assertSnapshot}) =\u003e {\n  const actual = {\n    a: 'a',\n    b: 1,\n    c: {\n      start: Date.now()\n      randomArray:  [\n        Math.random(),\n        Math.random(),\n      ]\n    }\n  }\n  const masks = ['/c/start', '/c/randomArray/*']\n  assertSnapshot(actual, masks);\n});\n```\n\nMasked snapshot:\n\n```\n'Test with masks': {\n    a: 'a',\n    b: 1,\n    c: {\n      start: '[MASKED number]',\n      randomArray: [\n        '[MASKED number]',\n        '[MASKED number]',\n      ],\n    },\n  },\n```\n\n### Snapshot Management (Exercise from CLI)\n\n#### New snapshots / Validate\n\nValidate existing snapshots or create new snapshots\n\n```\ndeno test --allow-write --allow-read --unstable\n```\n\n#### Filtered snapshot update\n\nOnly updates snapshots for tests being executed. Honors `ignore` and `only`\nattributes from `Deno.TestDefinition`\n\n```\ndeno test --allow-write --allow-read --unstable --filter \"/.*another.*/\" -- --update\n```\n\nor\n\n```\ndeno test --allow-write --allow-read --unstable --filter \"/.*another.*/\" -- --u\n```\n\n#### Refresh snapshots\n\nUpdate all snapshots, deleting any un-executed snapshots. Only does so if a\ntest-suite is executed\n\n```\ndeno test --allow-write --allow-read --unstable -- --refresh\n```\n\nor\n\n```\ndeno test --allow-write --allow-read --unstable -- --r\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyp3rflow%2Fsnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyp3rflow%2Fsnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyp3rflow%2Fsnap/lists"}