Excessibility.TelemetryCapture (Excessibility v0.17.0)

Copy Markdown View Source

Telemetry-based automatic snapshot capture for LiveView tests.

Attaches to Phoenix LiveView telemetry events to automatically capture snapshots when LiveView events occur, with no test code changes required.

Summary

Functions

Attaches telemetry handlers for automatic snapshot capture.

Clears all captured snapshots.

Detaches telemetry handlers.

The Ecto [..., :query] telemetry events for the configured :ecto_repos.

Returns and clears the Ecto queries accumulated in the current process since the last flush, oldest first. Called at each captured event so queries are attributed to the event that ran them.

Retrieves all captured snapshots and clears the table.

Handles telemetry events and captures snapshots.

Writes captured snapshots to timeline.json.

Functions

attach()

Attaches telemetry handlers for automatic snapshot capture.

Call this before running tests to enable auto-capture.

clear_snapshots(test_name \\ nil)

Clears all captured snapshots.

detach()

Detaches telemetry handlers.

ecto_query_events()

The Ecto [..., :query] telemetry events for the configured :ecto_repos.

flush_ecto_queries()

Returns and clears the Ecto queries accumulated in the current process since the last flush, oldest first. Called at each captured event so queries are attributed to the event that ran them.

get_snapshots()

Retrieves all captured snapshots and clears the table.

handle_event(list, measurements, metadata, config)

Handles telemetry events and captures snapshots.

write_snapshots(test_name)

Writes captured snapshots to timeline.json.

Note: HTML snapshot files are NOT generated from telemetry capture. For real accessibility testing, use html_snapshot(view) in your tests to capture actual rendered HTML.

Runs in the on_exit installed by use Excessibility, so a failure here is logged rather than raised — instrumentation must not fail the test it observes.