{"id":18622514,"url":"https://github.com/mindreframer/nap","last_synced_at":"2025-08-19T08:34:31.792Z","repository":{"id":46282145,"uuid":"418706188","full_name":"mindreframer/nap","owner":"mindreframer","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-03T00:24:37.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-18T07:54:11.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/mindreframer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-10-18T23:52:48.000Z","updated_at":"2022-12-07T21:44:50.000Z","dependencies_parsed_at":"2022-09-14T05:32:48.167Z","dependency_job_id":null,"html_url":"https://github.com/mindreframer/nap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mindreframer/nap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindreframer%2Fnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindreframer%2Fnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindreframer%2Fnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindreframer%2Fnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mindreframer","download_url":"https://codeload.github.com/mindreframer/nap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindreframer%2Fnap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271084468,"owners_count":24696515,"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-08-18T02:00:08.743Z","response_time":89,"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":[],"created_at":"2024-11-07T04:17:24.528Z","updated_at":"2025-08-19T08:34:31.766Z","avatar_url":"https://github.com/mindreframer.png","language":"Elixir","readme":"# Nap - give your test suite a refreshing nap!\n\n![CI](https://github.com/mindreframer/nap/actions/workflows/ci.yml/badge.svg)\n\n[Jest](https://jestjs.io/) - inspired snapshotting test package for Elixir. It's quite general and can be used for all snapshotting purposes, not just for REST API testing.\n\nFeatures:\n\n- frictionless setup\n- succinct and minimal API without much cognitive overhead (`napshot` / `assert_nap(currnap, YOURVALUE)`)\n- no need to provide explicit snapshot file names\n- support for all basic Elixir/Erlang data structures (PIDs, functions, file handles, etc not supported)\n- support for multiple snapshot assertions per test case\n- support for interactive snapshot updates, to keep your test maintenance minimal\n- snapshots are stored in plain-text, so Git diffing is supported\n- the overhead compared to manual inline assertions is quite low, in synthetic benchmarks I had numbers of roughly 2-4x slower (if your test suite is dominated by comparisons of static values)\n\n## Example\n\n```elixir\ndefmodule NapTestDriveTest do\n  use ExUnit.Case, async: true\n  use Nap.TestCase\n\n  defmodule MyStruct, do: defstruct a: nil, b: nil\n\n  test \"normal ExUnit test\" do\n    assert 1 == 1\n  end\n\n  napshot \"nap snapshot test case\" do\n    assert 1 == 1\n    assert_nap(currnap, 100)\n    assert_nap(currnap, 10.0)\n    assert_nap(currnap, %{a: 2})\n    assert_nap(currnap, {:also, :with, \"tuples\"})\n    assert_nap(currnap, \"string\")\n    assert_nap(currnap, %{a: \"long\n    multistring\n    text\n\n    works fine, too\"})\n    assert_nap(currnap, %MyStruct{a: 1, b: 2})\n  end\n\n  napshot \"another nap snapshot test case\" do\n    assert 1 == 1\n    assert_nap(currnap, %{a: 2 + 3})\n  end\nend\n\n```\n\n## Tutorial\n\n```\n# run with interactive snapshot update (blocks for user input)\n## with async tests the STDOUT is messed up... Not sure, how to approach it properly\n\n$ nap_interactive=true mix test / nap_i=true mix test\n\n# update all mismatching snapshots\n$ nap_update=true mix test / nap_u=true mix test\n\n# plain run, fails on mismatching snapshots\n$ mix test\n```\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `nap` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:nap, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/nap](https://hexdocs.pm/nap).\n\n### Todo\n\n- [ ] support ignored possibly nested keys in maps\n- [ ] support updating all snapshots without interactive confirmation\n\n### Inspiration\n\n- https://github.com/sb8244/elixir_response_snapshot\n- https://github.com/dczajkowski/snapshy\n- https://github.com/assert-value/assert_value_elixir\n- https://github.com/jfrolich/snapshot\n- https://github.com/sebastiandedeyne/snapshots\n\n### Links\n\n- [JSON Lines](https://jsonlines.org/)\n- [Json Term Elixir Package](https://github.com/kaaboaye/json_term)\n- [ETS](https://elixirschool.com/en/lessons/storage/ets)\n- [The New Scalable ETS ordered_set](https://blog.erlang.org/the-new-scalable-ets-ordered_set/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmindreframer%2Fnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmindreframer%2Fnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmindreframer%2Fnap/lists"}