Playwright Test's html reporter as an ExUnit formatter: a self-contained HTML report of the
run, written to playwright-report/ when the suite finishes, with the report app the driver
ships (the one npx playwright show-report serves). It prints nothing else, so it runs next to
ExUnit.CLIFormatter:
mix test --formatter ExUnit.CLIFormatter --formatter Playwright.Test.HTMLFormatterOr in test/test_helper.exs:
ExUnit.start(formatters: [ExUnit.CLIFormatter, Playwright.Test.HTMLFormatter])Open it with mix playwright.show_report (its trace links need it served over HTTP).
The report lists each test file's tests, with each test's status, duration, errors (ExUnit's
text of each failure, with the source around it), steps (Playwright.Test.step/2,3, the
driver calls and the matchers, the snippet of the line of each), annotations
(Playwright.Test.annotate/1, Playwright.Test.fail/2) and attachments: those of
Playwright.Test.attach/2 and the artifacts (trace, screenshot, video, error-context),
copied to data/ under their SHA-1, and with a trace, the trace viewer in trace/, which opens
it from the test's page. A describe is the test's path, a project of parameterize:
(Playwright.Test.parameters/1) its project. A failed setup_all is an error of the run, and
its tests have no results.
The options are config :playwright, :test, html_report: [...], upstream's reporter: [['html', { ... }]], each overridden by its environment variable:
:output_folder(PLAYWRIGHT_HTML_OUTPUT_DIR) -"playwright-report"by default, relative to the working directory. The formatter deletes it first: keep it apart fromoutput_dir.:open(PLAYWRIGHT_HTML_OPEN) -:never(default, a deviation from upstream's"on-failure": the run prints themix playwright.show_reportcommand and exits),:alwaysor:on_failure(or upstream's strings): serve the report and open it in the browser after the run, asmix playwright.show_reportdoes, which keepsmix testrunning until you press Ctrl+C. Never on CI (CIset), when the standard output isn't a terminal, or under a coding agent (CLAUDECODE,COPILOT_CLI), as upstream's. Another value raises when the config is read.:host,:port(PLAYWRIGHT_HTML_HOST,PLAYWRIGHT_HTML_PORT) - where:openserves it.:title(PLAYWRIGHT_HTML_TITLE) - the report's title.:attachments_base_url(PLAYWRIGHT_HTML_ATTACHMENTS_BASE_URL) -"data/"by default: the URL of the attachments, for a report whosedata/is hosted elsewhere.:no_snippets,:no_copy_prompt,:do_not_inline_assets,:merge_files(PLAYWRIGHT_HTML_NO_SNIPPETS, ...:"false"or"0"isfalse, another valuetrue) - no source snippets for the steps, no button that copies a failure's prompt, the report app inreport.jsandreport.cssnext toindex.htmlinstead of inlined, and the report app's option to merge the files.
Deviations: a test has the result of this run only, so a test that passes under mix test --failed (Playwright.Test.info/0's retry 1) shows one result, flaky, as in
Playwright.Test.JSONFormatter; the results have no worker (-1: ExUnit runs modules, not
workers); an error's source frame and a step's snippet have no caret (ExUnit's locations have
no column) and no syntax highlighting (upstream highlights JS); the tests have no tags
(ExUnit's tags aren't Playwright's), and stderr is never captured (see "Output" in
Playwright.Test). Not ported: testFilter options (mix test's filters choose the tests).
Ported from packages/playwright/src/reporters/html.ts.
Summary
Functions
Returns a specification to start this module under a supervisor.
Upstream's showHTMLReport: serves the report in report_folder (a folder, or a .zip of
one; nil for the default folder) on host ("localhost") and port (9323 if free, else
any), opens it in the browser, at the test test_id if given, and serves until the VM stops.
mix playwright.show_report calls it.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec show_html_report( Path.t() | nil, String.t() | nil, pos_integer() | nil, String.t() | nil ) :: no_return()
Upstream's showHTMLReport: serves the report in report_folder (a folder, or a .zip of
one; nil for the default folder) on host ("localhost") and port (9323 if free, else
any), opens it in the browser, at the test test_id if given, and serves until the VM stops.
mix playwright.show_report calls it.