Axe DevTools Node Reporter API Reference

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

API Reference for the @axe-devtools/reporter package

Not for use with personal data

This document describes the methods provided by the AxeDevToolsReporter class.

The AxeDevToolsReporter class extends the AxeDevToolsLogger class (from the @axe-devtools/logger package), so you can create an instance of AxeDevToolsReporter and call methods offered by the AxeDevToolsLogger class. See the Axe DevTools Logger Reference for more information on the methods provided by the AxeDevToolsLogger class.

Method signatures on this page are written in TypeScript notation, matching the type declarations bundled with the package. The usage examples are JavaScript, and they compile unchanged in TypeScript. For side-by-side JavaScript and TypeScript versions of a complete file, see Generating Reports.

Constructor

constructor(reportName: string, directory?: string)

Example usage:

const axeReporter = new AxeDevToolsReporter("AxeDevTools-Results", "./test-results/");

Parameters

Name Type Description
reportName string The title of the report. The reportName value will become the first segment of the JSON results file name.
directory string (optional) Directory where the report will be written. Directories will be recursively created if they do not already exist.

Methods

Each of these methods creates the specified report from the results JSON file that is produced by the logTestResult method.

Name Description
buildCSV Create a CSV report
buildEARL Create a W3C EARL JSON-LD report
buildHTML Create an HTML report
buildJUnitXML Create an XML report

buildCSV

Creates a CSV file from the results JSON file created by the logTestResult method.

buildCSV(directory: string, userAgent?: string, filterOpts?: string[]): Promise<void>;

Parameters

Name Type Description
directory string The directory to create the output .csv file. All directories will be recursively created if they do not already exist.
userAgent string (optional) Only results with the specified user agent will appear in the .csv file
filterOpts string[] (optional) An array of filter options for selecting results.

Returns

Promise<void>

buildEARL

Creates a W3C EARL (Evaluation and Report Language) JSON-LD file named axe-devtools-results.earl.json in the directory specified.

note

EARL output does not support Axe DevTools Mobile results. If mobile results are present, buildEARL throws an error before writing any file.

buildEARL(directory: string, userAgent?: string): Promise<void>;

Parameters

Name Type Description
directory string The directory to create the output .earl.json file. All directories will be recursively created if they do not already exist.
userAgent string (optional) Only results with the specified user agent will appear in the EARL report

Returns

Promise<void>

buildHTML

Creates an HTML file in the directory specified from the accessibility results JSON file.

buildHTML(directory: string, userAgent?: string, renderOptions?: RenderOptions): Promise<void>;

Parameters

Name Type Description
directory string The directory to create the output .html file. All directories will be recursively created if they do not already exist.
userAgent string (optional) Only results with the specified user agent will appear in the .html report file
renderOptions RenderOptions (optional) Controls how the report is pre-rendered into static markup. See Pre-rendering HTML reports.

Returns

Promise<void>

RenderOptions

Passed to buildHTML to control how the report is pre-rendered into static markup. Every option is optional, and each one has an environment variable that applies when the option is not set. The renderer is selected once per call, so these options apply to every report that call builds.

Name Type Default Description
browserPath string none Path to a browser executable used to pre-render the report. Environment variable: AXE_DEVTOOLS_REPORTER_BROWSER_PATH.
autoDetectBrowser boolean true Whether to look for a Chromium-based browser already installed on this machine when no browser path is given and jsdom is not installed. Set it to false to skip pre-rendering rather than run a browser the reporter discovered itself. Environment variable: AXE_DEVTOOLS_REPORTER_BROWSER_AUTO_DETECT.
noSandbox boolean false Disables the browser sandbox. Leave the sandbox enabled unless you are in a trusted, constrained environment that cannot support it. Environment variable: AXE_DEVTOOLS_REPORTER_BROWSER_NO_SANDBOX.
maxBufferBytes number 67108864 (64 MB) Maximum amount of rendered output to buffer from the browser. Raise this if a large report fails to render with a buffer overflow error.
virtualTimeBudgetMs number 5000 How long the browser is given to render the report before its content is captured. Raise this if a large report is written without its content.
renderTimeoutMs number 30000 Time limit for the browser render. A browser that never exits is stopped and the render fails.
distDirectory string the copy included with the package Directory holding the report's client assets. Set this only when the package's files are not where its own module resolution expects them, such as when your application is bundled into a single executable.
note

The browser is only used when the path resolves to a file that exists. If you set browserPath (or AXE_DEVTOOLS_REPORTER_BROWSER_PATH) to a path that does not exist, the reporter moves on to the next rendering method instead of reporting an error, so verify the path if you need a misconfiguration to surface.

Auto-detection starts a browser process for each report. On a large batch run, or on a build machine where starting a browser the reporter discovered itself is unwanted, set autoDetectBrowser to false and either supply browserPath or install jsdom.

buildJUnitXML

Creates a JUnit XML file in the directory specified from the JSON accessibility results.

buildJUnitXML(directory: string, userAgent?: string): Promise<void>;

Parameters

Name Type Description
directory string The directory to create the output .xml file. All directories will be recursively created if they do not already exist.
userAgent string (optional) Only results with the specified user agent will appear in the .xml report file

Returns

Promise<void>