Axe DevTools Node Logger API Reference
API Reference for the @axe-devtools/logger package
This document describes the methods implemented by the AxeDevToolsLogger class in the @axe-devtools/logger package.
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 the import syntax in each language, see Logging with Axe DevTools Node APIs.
Constructor
Creates an Axe DevTools logger which you can use to write a JSON results file to the specified directory. You can use the Reporter API to generate reports in several different formats from this results file.
constructor(reportName: string, directory?: string)Example usage:
let logger = new AxeDevToolsLogger("Report Name", "directory-name");Because the AxeDevToolsReporter class inherits from this class, you typically invoke methods in the AxeDevToolsLogger class via your AxeDevToolsReporter instance.
Parameters
| Name | Type | Description |
|---|---|---|
| reportName | string | The name of the report, which will be the first part of the output results file name. |
| directory | string (optional) | The directory where the logger API will write the JSON results file |
Methods
| Name | Description |
|---|---|
| getTestResults | Returns an array of test results. |
| logTestResult | Log test results. |
getTestResults
Returns an array of Axe DevTools test results. The results can be filtered by userAgent.
public getTestResults(userAgent?: string): AxeDevToolsResults[] Parameters
| Name | Type | Description |
|---|---|---|
| userAgent | string (optional) | Specifies the userAgent for filtering the results. Only results where the userAgent matches will be written to disk. |
Returns
An array of AxeDevToolsResults
logTestResult
Logs the current accessibility result to disk. See Reporter Code Examples for code examples.
public logTestResult(
id: string,
finding: Findings,
options?: LogTestResultOptions
): void
Parameters
| Name | Type | Description |
|---|---|---|
| id | string | An user-supplied identifier for the finding |
| finding | Findings object | The Findings object obtained from running a test, usually results object from run() or analyze() |
| options | LogTestResultsOptions object (optional) | Logger configuration options |
Return
Nothing is returned
