# `Excessibility.Snapshot`
[🔗](https://github.com/lessthanseventy/excessibility/blob/v0.18.1/lib/snapshot.ex#L1)

Core snapshot generation and file management.

This module handles:

- Converting test sources to HTML snapshots
- Writing snapshots to the filesystem

## File Locations

Snapshots are stored in `test/excessibility/html_snapshots/` by default.
Configure with `:excessibility_output_path` to change the base directory.

## Workflow

1. Run tests to generate snapshots
2. Run `mix excessibility.baseline` to lock in a known-good state
3. Run `mix excessibility.compare` to diff against baseline after changes

This module is typically used via the `Excessibility.html_snapshot/2` macro
rather than called directly.

# `html_snapshot`

```elixir
@spec html_snapshot(term(), Macro.Env.t(), module(), keyword()) :: term()
```

Generates an HTML snapshot from a test source.

## Parameters

- `source` - A `Plug.Conn`, `Wallaby.Session`, `Phoenix.LiveViewTest.View`,
  or `Phoenix.LiveViewTest.Element`
- `env` - The `__ENV__` of the calling test (injected by macro)
- `module` - The `__MODULE__` of the calling test (injected by macro)
- `opts` - Keyword list of options

## Options

- `:name` - Custom filename (default: `ModuleName_LineNumber.html`)

- `:screenshot?` - Generate PNG screenshot via Playwright (default: `false`)
- `:open_browser?` - Open snapshot in browser after writing (default: `false`)
- `:cleanup?` - Delete existing snapshots for this module first (default: `false`)

## Returns

The original `source`, unchanged (for pipeline compatibility).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
