{"id":15552335,"url":"https://github.com/bahmutov/subset-shot","last_synced_at":"2025-09-29T00:32:56.625Z","repository":{"id":57374001,"uuid":"87973188","full_name":"bahmutov/subset-shot","owner":"bahmutov","description":"Snapshot testing where new value can be a superset of the saved snapshot","archived":false,"fork":false,"pushed_at":"2017-04-18T21:51:23.000Z","size":24,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T21:46:27.160Z","etag":null,"topics":["ava","jest","mocha","node","nodejs","qunit","snapshot","snapshot-testing","subset"],"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/bahmutov.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}},"created_at":"2017-04-11T19:48:27.000Z","updated_at":"2019-08-07T01:30:59.000Z","dependencies_parsed_at":"2022-09-11T07:12:16.124Z","dependency_job_id":null,"html_url":"https://github.com/bahmutov/subset-shot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/bahmutov/subset-shot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fsubset-shot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fsubset-shot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fsubset-shot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fsubset-shot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/subset-shot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fsubset-shot/sbom","scorecard":{"id":223582,"data":{"date":"2025-08-11","repo":{"name":"github.com/bahmutov/subset-shot","commit":"ef84f26a11a6fb1a5ba6b9e6d819bfd842269714"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T03:09:38.446Z","repository_id":57374001,"created_at":"2025-08-17T03:09:38.446Z","updated_at":"2025-08-17T03:09:38.446Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275384116,"owners_count":25454910,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"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":["ava","jest","mocha","node","nodejs","qunit","snapshot","snapshot-testing","subset"],"created_at":"2024-10-02T14:16:18.094Z","updated_at":"2025-09-29T00:32:56.329Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# subset-shot\n\n\u003e Snapshot testing where new value can be a superset of the saved snapshot\n\n[![NPM][npm-icon] ][npm-url]\n\n[![Build status][ci-image] ][ci-url]\n[![semantic-release][semantic-image] ][semantic-url]\n[![js-standard-style][standard-image]][standard-url]\n\n## Related\n\nThis is a sister project to [snap-shot](https://github.com/bahmutov/snap-shot) and\n[schema-shot](https://github.com/bahmutov/schema-shot)\n\n## Why\n\nImagine you have an API returning list of Oscar-winning movies. At some point it returns\nN movie titles, including \"Braveheart\", \"Titanic\" and \"The Artist\" \n(see example page [here](http://www.today.com/popculture/complete-list-every-best-picture-oscar-winner-ever-t107617)).\nYou write an end to end test and would like to use \n[snapshot testing](https://facebook.github.io/jest/blog/2016/07/27/jest-14.html), but you cannot\nbecause at some point in February of the next year a new movie will be added and your \nsnapshot will have to be updated.\n\nThis module solves this problem by allowing *future values* to be a superset of the saved snapshot.\nIf API returns more movies - it is fine, as long as it returns all the ones already saved in the\nsnapshot.\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 6 or above.\n\n```sh\nnpm install --save-dev subset-shot\n```\n\n## Use\n\nThis module works using same [stack-walking, AST parsing magic](https://glebbahmutov.com/blog/snapshot-testing/)\nas [snap-shot](https://github.com/bahmutov/snap-shot) and \n[schema-shot](https://github.com/bahmutov/schema-shot). This means, just use it in any testing\nframework (like Ava, Jest, etc)\n\n```js\n// movies-spec.js\nconst subsetShot = require('subset-shot')\nit('Oscar movies', () =\u003e {\n  const list = ['Braveheart', 'Titanic']\n  subsetShot(list)\n})\n```\n\nThe snapshot file will have contents\n\n```js\n// movies-spec.js.subset-shot\nexports['Oscar movies'] = [\n  'Braveheart', \n  'Titanic'\n]\n```\n\nLater the API might return more movies, yet the same test still passes because the snapshot\nhas subset of the new data.\n\n```js\n// movies-spec.js\nconst subsetShot = require('subset-shot')\nit('Oscar movies', () =\u003e {\n  const list = ['Braveheart', 'Titanic', 'The Artist']\n  subsetShot(list)\n})\n```\n\nThe test still passes. But a test that all of the sudden returns empty list or nothing, or\na totally different set of movies (by confusing \"Best Picture\" with \"Best Director\" for example)\nfails.\n\n## Updating snapshots\n\nYou can show the snapshots but skip saving them (dry run) by running tests with \nenvironment variable `DRY=1 npm test`.\n\nYou can show and save snapshots by running tests with environment variable `SHOW=1 npm test`.\n\nYou can update saved snapshots by running tests with environment variable `UPDATE=1 npm test`.\n\n## Comparing objects\n\nA snapshot could be an object subset, compared using \n[obj-subset](https://github.com/kvnneff/obj-subset).\n\n```js\n// saved snapshot is {foo: 42}\nconst subsetShot = require('subset-shot')\nit('allows new properties', () =\u003e {\n  subsetShot({foo: 42, bar: 10}) // ok\n})\nit('requires value', () =\u003e {\n  subsetShot({foo: 20}) // exception, value should 42\n})\nit('requires matching key', () =\u003e {\n  subsetShot({foo2: 42}) // exception, wrong key name\n})\n```\n\n### Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2017\n\n* [@bahmutov](https://twitter.com/bahmutov)\n* [glebbahmutov.com](https://glebbahmutov.com)\n* [blog](https://glebbahmutov.com/blog)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/subset-shot/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/subset-shot.svg?downloads=true\n[npm-url]: https://npmjs.org/package/subset-shot\n[ci-image]: https://travis-ci.org/bahmutov/subset-shot.svg?branch=master\n[ci-url]: https://travis-ci.org/bahmutov/subset-shot\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fsubset-shot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fsubset-shot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fsubset-shot/lists"}