{"id":15552173,"url":"https://github.com/bahmutov/schema-shot","last_synced_at":"2026-03-07T12:01:15.840Z","repository":{"id":66012569,"uuid":"82135651","full_name":"bahmutov/schema-shot","owner":"bahmutov","description":"Framework-agnostic snapshot testing using \"schema by example\" for highly dynamic data","archived":false,"fork":false,"pushed_at":"2019-11-06T19:18:17.000Z","size":41,"stargazers_count":32,"open_issues_count":16,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-27T10:26:35.100Z","etag":null,"topics":["json-schema","schema","snapshot","testing"],"latest_commit_sha":null,"homepage":null,"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-16T03:39:07.000Z","updated_at":"2024-02-23T19:57:45.000Z","dependencies_parsed_at":"2023-03-10T23:28:16.723Z","dependency_job_id":null,"html_url":"https://github.com/bahmutov/schema-shot","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.11538461538461542","last_synced_commit":"f02d6a803c40caa068fa6a9c74a7642f89204a46"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/bahmutov/schema-shot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fschema-shot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fschema-shot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fschema-shot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fschema-shot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/schema-shot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fschema-shot/sbom","scorecard":{"id":223551,"data":{"date":"2025-08-11","repo":{"name":"github.com/bahmutov/schema-shot","commit":"f02d6a803c40caa068fa6a9c74a7642f89204a46"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/24 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":"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":"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":"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":"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T03:09:19.285Z","repository_id":66012569,"created_at":"2025-08-17T03:09:19.285Z","updated_at":"2025-08-17T03:09:19.285Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["json-schema","schema","snapshot","testing"],"created_at":"2024-10-02T14:10:53.152Z","updated_at":"2026-03-07T12:01:15.567Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schema-shot\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/bahmutov/schema-shot.svg)](https://greenkeeper.io/)\n\n\u003e Framework-agnostic snapshot testing using \"schema by example\" for highly dynamic data\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\nIf you like [snap-shot][snap-shot] (snapshot testing for any JS framework),\nbut have data that is hard to pin down, maybe this package will be useful.\nInstead of storing *literal* data snapshot, it stores [json-schema][json-schema]\nderived from a the snapshot object seen **first time** (using\n[validate-by-example][validate-by-example] to derive it). Next time an object\narrives, it will be validated against the *schema*. Any missing property,\nor new one will trigger an exception.\n\nRead [the blog post](https://glebbahmutov.com/blog/schema-shot/)\n\n## Example\n\nImagine we are fetching most popular item from an API service. Obviously\nit changes often, so we cannot just store it as a snapshot for direct\ncomparison. We could massage the data and derive\n[invariant snapshots][snapshot testing], but that is boilerplate code!\n\nInstead, use `schema-shot`!\n\n```sh\nnpm install --save-dev schema-shot\n```\n\nIn your test\n\n```js\n// spec.js\nconst schemaShot = require('schema-shot')\nit('returns most popular item', () =\u003e {\n  const top = api.getMostPopularItem()\n  schemaShot(top)\n})\n```\n\nSuppose first time it runs, the API returns `top = {id: '45a12e'}` - an object\nwith just its `id` property. The `__snapshots__/spec.js.schema-shot` file\nwill be saved with\n\n```js\nexports['returns most popular item 1'] = {\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"id\": {\n      \"type\": \"string\",\n      \"required\": true\n    }\n  },\n  \"additionalProperties\": false\n}\n```\n\nNow imagine the same day later running again. The API returns something else,\nbut the object still has same *shape*, just a different id `{id: 8812f0}`.\nThis object passes the schema validation step.\n\nA week later, the new API version gets deployed. Now it returns the top\nitem, but instead of `id` property, it returns `uuid` property. The test\nwill fail!\n\n```sh\n$ npm test\nError: schema difference\n  data has additional properties\n  data.id: is required\n```\n\n[json-schema]: http://json-schema.org/\n[validate-by-example]: https://github.com/bahmutov/validate-by-example\n[snapshot testing]: https://glebbahmutov.com/blog/snapshot-testing/\n\n## Returned value is schema object\n\nYou can inspect or even [snap-shot][snap-shot] the schema object.\n\n```js\nconst snapshot = require('snap-shot')\nconst schemaShot = require('schema-shot')\nit('returns schema object', () =\u003e {\n  const o = {name: 'my name'}\n  const schema = schemaShot(o)\n  snapshot(schema)\n})\n```\n\nBoth objects in this case will be\n\n```js\n{\n  '$schema': 'http://json-schema.org/draft-04/schema#',\n  type: 'object',\n  properties: {\n    name: { type: 'string', required: true }\n  },\n  additionalProperties: false\n}\n```\n\n## Inferred property formats\n\nA more specific property formats are inferred, see\n[validate-by-example#inferring-formats][inferring] and can be\n[overridden][overridden].\n\n```js\nconst person = {\n  name: 'Joe Smith',\n  email: 'joe@foo.com'\n}\n// let it infer that person.email has \"email\" format\nschemaShot(person)\n// or we can set it ourselves\nschemaShot(person, {email: 'email'})\n/*\n  schema properties\n  {\n    name: {type: 'string', required: true},\n    email: {type: 'string', required: true, format: 'email'}\n  }\n*/\n```\n\n[inferring]: https://github.com/bahmutov/validate-by-example#inferring-formats\n[overridden]: https://github.com/bahmutov/validate-by-example#overriding-formats\n\n## Dry run and showing the updates\n\nIf you just want to see what a new schema would be, without saving it,\nrun the tests with `DRY=1 npm test` option.\n\nIf you want to see the schema and save it, run the tests with `SHOW=1 npm test`\n\n## Arrays\n\nWhen training with arrays\n\n* All items in the array must pass the schema derived from the first object\n\n## Difference with snapshot testing\n\nThe schema shots do not store the direct information. A good example is\na test using [snap-shot][snap-shot] and [fake-todos][fake-todos] in\n[test/todos-spec.js](test/todos-spec.js). The snapshot test always fails\non the second run, because a returned todo is *different*. The JSON\nschema on the other hand stays consistent, as long as *fake-todos*\nreturns objects with same shape.\n\n```js\nconst snapshot = require('snap-shot')\nconst schemaShot = require('schema-shot')\nconst generate = require('fake-todos')\ndescribe('fake-todos', () =\u003e {\n  it.skip('returns a different todo', () =\u003e {\n    const todos = generate(1)\n    snapshot(todos[0])\n    /*\n      Fails of course, because every todo is different\n        1) fake-todos returns a different todo:\n           Error: snapshot difference\n      {\n        id: \"4e040570-...\" =\u003e \"129a55b4-...\"\n        what: \"do adults\" =\u003e \"skip chess\"\n      }\n    */\n  })\n  it('returns a todo', () =\u003e {\n    const todos = generate(1)\n    schemaShot(todos[0])\n  })\n})\n```\n\n[snap-shot]: https://github.com/bahmutov/snap-shot\n[fake-todos]: https://github.com/bahmutov/fake-todos\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](http://glebbahmutov.com)\n* [blog](http://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/schema-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/schema-shot.svg?downloads=true\n[npm-url]: https://npmjs.org/package/schema-shot\n[ci-image]: https://travis-ci.org/bahmutov/schema-shot.svg?branch=master\n[ci-url]: https://travis-ci.org/bahmutov/schema-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%2Fschema-shot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fschema-shot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fschema-shot/lists"}