{"id":15998157,"url":"https://github.com/plouc/gosnap","last_synced_at":"2025-06-14T04:36:53.631Z","repository":{"id":57489045,"uuid":"140480672","full_name":"plouc/gosnap","owner":"plouc","description":":camera: gosnap is a go package to perform snapshot testing","archived":false,"fork":false,"pushed_at":"2018-07-14T07:01:01.000Z","size":13,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T06:19:09.122Z","etag":null,"topics":["go","golang","snapshot-testing","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","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/plouc.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":"2018-07-10T19:53:44.000Z","updated_at":"2018-11-16T12:04:55.000Z","dependencies_parsed_at":"2022-08-29T10:30:21.803Z","dependency_job_id":null,"html_url":"https://github.com/plouc/gosnap","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/plouc%2Fgosnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plouc%2Fgosnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plouc%2Fgosnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plouc%2Fgosnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plouc","download_url":"https://codeload.github.com/plouc/gosnap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243894397,"owners_count":20365026,"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":["go","golang","snapshot-testing","testing"],"created_at":"2024-10-08T08:07:39.750Z","updated_at":"2025-03-18T01:31:26.383Z","avatar_url":"https://github.com/plouc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gosnap\n\n[![Build Status](https://travis-ci.org/plouc/gosnap.png?branch=master)](https://travis-ci.org/plouc/gosnap)\n[![GoDoc](https://godoc.org/github.com/plouc/gosnap?status.svg)](https://godoc.org/github.com/plouc/gosnap)\n[![GitHub license](https://img.shields.io/github/license/plouc/gosnap.svg)](https://github.com/plouc/gosnap/blob/master/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/plouc/gosnap)](https://goreportcard.com/report/github.com/plouc/gosnap)\n[![GitHub issues](https://img.shields.io/github/issues/plouc/gosnap.svg)](https://github.com/plouc/gosnap/issues)\n\n**gosnap** is a go package to perform snapshot testing.\n\nSnapshot testing is a convenient way to test large outputs with ease,\nthis package was initially created to test the [`go-gitlab-client` CLI](https://github.com/plouc/go-gitlab-client).\n\n## Install\n\n```\ngo get github.com/plouc/gosnap\n```\n\n## Usage\n\n**gosnap** requires a context to run, from which you can create snapshots.\n\n````go\npackage whatever\n\nimport (\n    \"testing\"\n    \"github.com/plouc/gosnap\"\n)\n\nfunc TestSomething(t *testing.T) {\n    // creates a new context\n    // snapshots will be stored inside the `snapshots` directory\n    ctx := gosnap.NewContext(t, \"snapshots\")\n\n    // creates a new snapshot\n    // it will be stored in `snapshots/my_first_snapshot.snap`\n    s := ctx.NewSnapshot(\"my_first_snapshot\")\n    \n    actual := DoSomethingWhichReturnsString()\n    \n    // this will load the snapshot content and check it matches `actual`\n    s.AssertString(actual)\n}\n````\n\nThis will check that `actual` matches current snapshot (`./snapshots/my_first_snapshot.snap`) content.\n\nThe first time you run your tests, the snapshot will be created automatically,\nthen if the current result does not match snapshot's content, you'll have to\nupdate it, you can add a command-line flag to the `go test command` to do so:\n\n```\n# will update all stale snapshots\ngo test -v ./... -args -update all\n\n# will just update snapshot whose name is `my_snapshot`\ngo test -v ./... -args -update my_snapshot\n```\n\nFor complete usage of **gosnap**, see the full [package docs](https://godoc.org/github.com/plouc/gosnap).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplouc%2Fgosnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplouc%2Fgosnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplouc%2Fgosnap/lists"}