axe-playwright-report
Version:
Playwright + axe-core integration to run accessibility scans and build HTML dashboard reports.
28 lines (27 loc) • 1.42 kB
TypeScript
/**
* A decorator that runs an accessibility scan using Axe after executing the decorated method.
*
* **Usage Instructions**:
* 1. This decorator should be assigned to methods within a **Page Object** class.
* 2. The Page Object class should contain a parameter of type `Page` (otherwise, the accessibility scan will not be executed).
* 3. The accessibility scan is performed after the body of the method is executed. The method will only be executed if the accessibility scan passes.
*
* The scan checks for common accessibility issues using the Axe-core library.
*
* @template This - The type of the class instance (or object) on which the decorated method is called.
* @template Args - The type of arguments the decorated method takes.
* @template Return - The return type of the decorated method.
*
* @param target - The method to be decorated. This method will be wrapped so that the Axe accessibility scan runs after it.
*
* @returns A new function that runs the accessibility scan after executing the original method.
* It returns a `Promise` that resolves to the return value of the original method.
*
* @example
* @axeScan
* async someMethod() {
* this.page.getByText('Hello World').click();
* }
* }
*/
export declare function axeScan<This, Args extends any[], Return>(): (target: (this: This, ...args: Args) => Promise<Return>) => (this: This, ...args: Args) => Promise<Return>;