Excessibility (Excessibility v0.14.0)
View SourceAccessibility 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
endSupported Sources
The html_snapshot/2 macro works with:
Plug.Conn- Controller test responsesWallaby.Session- Browser-based feature testsPhoenix.LiveViewTest.View- LiveView test viewsPhoenix.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.htmland.bad.htmlon 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 for full documentation.
Summary
Functions
Sets up the module for snapshot testing by importing Excessibility.
Captures an HTML snapshot from a test source for accessibility testing.
Functions
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 ExcessibilityAuto-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
Captures an HTML snapshot from a test source for accessibility testing.
Returns the source unchanged, allowing use in pipelines.
Parameters
source- APlug.Conn,Wallaby.Session,Phoenix.LiveViewTest.View, orPhoenix.LiveViewTest.Elementopts- 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)