{"id":21832671,"url":"https://github.com/tool3/snaptdout","last_synced_at":"2026-05-06T12:38:56.400Z","repository":{"id":57142082,"uuid":"319886946","full_name":"tool3/snaptdout","owner":"tool3","description":"⚡︎ stdout snapshot testing","archived":false,"fork":false,"pushed_at":"2021-10-03T07:23:05.000Z","size":362,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-26T09:27:05.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/tool3.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":"2020-12-09T08:12:10.000Z","updated_at":"2022-08-24T12:40:33.000Z","dependencies_parsed_at":"2022-09-05T07:50:29.943Z","dependency_job_id":null,"html_url":"https://github.com/tool3/snaptdout","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tool3%2Fsnaptdout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tool3%2Fsnaptdout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tool3%2Fsnaptdout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tool3%2Fsnaptdout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tool3","download_url":"https://codeload.github.com/tool3/snaptdout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244807278,"owners_count":20513607,"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-11-27T19:24:47.888Z","updated_at":"2026-05-06T12:38:56.358Z","avatar_url":"https://github.com/tool3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./shellfies/logo.png\" /\u003e   \n\n# install\n`npm i -D snaptdout`\n\n# how does it work ?\nsnaptdout saves a copy of stdout to a `.json` file equivalent to the test file name, which should be committed to git.\n\n# usage\nsnaptdout is a drop-in snapshot testing tool, you can use it in any testing framework by simply calling it with the expected `stdout`:\n\n```javascript\ndescribe('snapshot testing', () =\u003e {\n    it('should snapshot stdout', async () =\u003e {\n        const stdout = ` \n        this is a \n        complicated cli\n        str ing\n        `\n        await snap(stdout, 'snapshot name');\n    });\n});\n```\n\nall consequential tests from this file will be compared to the snapshot.\n\n\u003e while snapshot name is optional, it is highly recommended.   \n\u003e if you do not provide a snapshot name, snaptdout will save the line and column of the running test as keys in the `.json` file.\n\n# config \nyou can provide config through your `package.json`, like so:\n\n```json\n...\n\"snaptdout\": {\n    \"snapshotsDir\": \"relative/to/root/project/directory\"\n}\n...\n```\n\nyou can also provide the config as a third paremeter.\nsnapshot specific config overrides any global config.\n```javascript\nconst stdout = '\\x1b[32;7mHEY THERE\\x1[0m';\nawait snap(stdout, 'hey', {ignoreAnsi: true});\n```\n\n##  `snapshotsDir`\nsnapshots directory.   \nunder this directory all snapshots files will be saved.\n\n\u003e default: test file location.\n\n##  `snapshotsPrefix`\nsnapshots file prefix.   \n\n\u003e default: ''.\n\n##  `ignoreAnsi`\nignore ansi formatting characters (`\\x1b[32m` || `[32m`).   \nif set to `true` - `snaptdout` will save the raw string without formatting and use that for future comparisons.   \n\n\u003e default: false.\n\n##  `formattedOutput`\nshow formatted output after error message.   \n\n\u003e default: true.\n\n# features\n## lightweight\n`snaptdout` has no dependencies, and a minimal footprint.\n\n## 0 setup\nyou can simply `require` / `import` `snaptdout` and use it out of the box.\n\n## simple.\n`snaptdout` uses simple `.json` files to store the string we refer to as a `snapshot`.   \nno binaries. nothing fancy.\n\n## great diffs\nwhen output based tests break, you need to know **exactly** where.   \n[![](https://img.shields.io/static/v1?label=created%20with%20shellfie\u0026message=📸\u0026color=pink)](https://github.com/tool3/shellfie)   \n\n![](./img/error.png)\n\n# examples\nyargs cli test example\n```javascript\nconst {exec} = require('child_process');\nconst execute = require('util').promisify(exec);\nconst snap = require('snaptdout');\n\ndescribe(('help test') =\u003e {\n    it('should show the correct help text', async () =\u003e {\n        const {stdout} = await execute('node index.js --help');\n        await snap(stdout, 'help');\n    });\n});\n```\n\nignore ansi characters for specific test\nonly tests for text and spacing\n```javascript\nawait snap('randomly formatted string', 'snapshot name', {ignoreAnsi: true});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftool3%2Fsnaptdout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftool3%2Fsnaptdout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftool3%2Fsnaptdout/lists"}