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

Accessibility snapshot testing for Phoenix applications.

Excessibility captures HTML snapshots during tests and runs them through axe-core
for WCAG compliance checking.

## Usage

Add `use Excessibility` to your test modules:

    defmodule MyAppWeb.PageControllerTest do
      use MyAppWeb.ConnCase
      use Excessibility

      test "home page is accessible", %{conn: conn} do
        conn = get(conn, "/")
        html_snapshot(conn)
        assert html_response(conn, 200)
      end
    end

## Supported Sources

The `html_snapshot/2` macro works with:

- `Plug.Conn` - Controller test responses
- `Wallaby.Session` - Browser-based feature tests
- `Phoenix.LiveViewTest.View` - LiveView test views
- `Phoenix.LiveViewTest.Element` - LiveView elements

## Options

- `:name` - Custom filename (default: auto-generated from module/line)
- `:prompt_on_diff` - Interactive diff resolution (default: `true`)
- `:tag_on_diff` - Save `.good.html` and `.bad.html` on diff (default: `true`)
- `:screenshot?` - Generate PNG screenshots (default: `false`)
- `:open_browser?` - Open snapshot in browser (default: `false`)
- `:cleanup?` - Delete existing module snapshots first (default: `false`)

See the [README](readme.html) for full documentation.

# `__using__`
*macro* 

Sets up the module for snapshot testing by importing `Excessibility`.

This makes the `html_snapshot/1` and `html_snapshot/2` macros available
in your test module without needing to fully qualify them.

## Example

    use Excessibility

## Auto-Capture

Use `@tag capture_snapshots: true` to automatically capture snapshots:

    @tag capture_snapshots: true
    test "user flow", %{conn: conn} do
      {:ok, view, _html} = live(conn, "/dashboard")
      # Snapshots captured automatically
    end

# `html_snapshot`
*macro* 

Captures an HTML snapshot from a test source for accessibility testing.

Returns the source unchanged, allowing use in pipelines.

## Parameters

- `source` - A `Plug.Conn`, `Wallaby.Session`, `Phoenix.LiveViewTest.View`,
  or `Phoenix.LiveViewTest.Element`
- `opts` - Keyword list of options (see module docs)

## Examples

    # Basic snapshot
    html_snapshot(conn)

    # With options
    html_snapshot(conn,
      name: "login_form.html",
      screenshot?: true,
      prompt_on_diff: false
    )

    # In a pipeline
    conn
    |> get("/")
    |> html_snapshot()
    |> html_response(200)

---

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