From 7cdc2dc50c756ab4123af110b37cfe20fed139c2 Mon Sep 17 00:00:00 2001 From: Abhinaba Ghosh Date: Fri, 12 Sep 2025 09:13:15 +0000 Subject: [PATCH 1/3] docs(types): add full type definitions and JSDoc for axe-playwright methods --- src/types/axe-playwright.d.ts | 129 ++++++++++++++++++++++++++++++++++ tsconfig.json | 2 +- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/types/axe-playwright.d.ts diff --git a/src/types/axe-playwright.d.ts b/src/types/axe-playwright.d.ts new file mode 100644 index 0000000..6c18bce --- /dev/null +++ b/src/types/axe-playwright.d.ts @@ -0,0 +1,129 @@ +import { Page } from 'playwright'; +import { + AxeResults, + ElementContext, + Result, + RunOptions, + Spec, + ImpactValue, + Locale, + Rule, + Check +} from 'axe-core'; + +export interface NodeViolation { + target: string; + html: string; + violations: string; +} + +export interface Aggregate { + [key: string]: { + target: string; + html: string; + violations: number[]; + }; +} + +export interface Reporter { + report(violations: Result[]): Promise; +} + +export interface axeOptionsConfig { + axeOptions?: RunOptions; +} + +export interface ConfigOptions { + branding?: { + brand?: string; + application?: string; + }; + reporter?: 'v1' | 'v2' | 'no-passes'; + checks?: Check[]; + rules?: Rule[]; + locale?: Locale; + axeVersion?: string; +} + +export type AxeOptions = { + includedImpacts?: ImpactValue[]; + detailedReport?: boolean; + detailedReportOptions?: { html?: boolean }; + verbose?: boolean; +} & axeOptionsConfig; + +/** + * Injects axe executable commands in the active window + * @param page Playwright Page object + */ +export function injectAxe(page: Page): Promise; +/** + * Configures axe runtime options + * @param page Playwright Page object + * @param configurationOptions Axe configuration options + */ +export function configureAxe(page: Page, configurationOptions?: ConfigOptions): Promise; +/** + * Runs axe-core tools on the relevant page and returns all results + * @param page Playwright Page object + * @param context Optional element context + * @param options Optional axe run options + */ +export function getAxeResults(page: Page, context?: ElementContext, options?: RunOptions): Promise; +/** + * Runs axe-core tools and returns all accessibility violations detected on the page + * @param page Playwright Page object + * @param context Optional element context + * @param options Optional axe run options + */ +export function getViolations(page: Page, context?: ElementContext, options?: RunOptions): Promise; +/** + * Report violations using the provided reporter + * @param violations Array of axe-core Result objects + * @param reporter Reporter instance + */ +export function reportViolations(violations: Result[], reporter: Reporter): Promise; +/** + * Performs Axe validations and reporting + * @param page Playwright Page object + * @param context Optional element context + * @param axeOptions Axe options + * @param skipFailures Whether to skip failures + * @param reporter Reporter instance or type + * @param options Additional options + */ +export function checkA11y( + page: Page, + context?: ElementContext, + axeOptions?: AxeOptions, + skipFailures?: boolean, + reporter?: Reporter | 'default' | 'html' | 'junit' | 'v2', + options?: any +): Promise; + +/** + * Filters violations by impact values + * @param violations Array of axe-core Result objects + * @param includedImpacts Array of impact values to include + */ +export function getImpactedViolations( + violations: Result[], + includedImpacts?: ImpactValue[] +): Result[]; + +/** + * Asserts or warns based on the presence of violations and skipFailures flag + * @param violations Array of axe-core Result objects + * @param skipFailures Whether to skip failures + */ +export function testResultDependsOnViolations( + violations: Result[], + skipFailures: boolean +): void; + +/** + * Aggregates and describes violations for reporting + * @param violations Array of axe-core Result objects + * @returns Array of NodeViolation objects + */ +export function describeViolations(violations: Result[]): NodeViolation[]; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 5d17d65..70a8eba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "esModuleInterop": true, "outDir": "dist", "noImplicitAny": false, - "types": ["node", "jest"] + "types": ["node", "jest", "axe-playwright"] }, "exclude": ["node_modules"], "include": ["src/"] From 4ce358c7ec6b2ad20f5452dc463e01e732f15c82 Mon Sep 17 00:00:00 2001 From: Abhinaba Ghosh Date: Fri, 12 Sep 2025 09:17:44 +0000 Subject: [PATCH 2/3] fix(types): ensure custom axe-playwright types are resolved via typeRoots --- src/types/axe-playwright/index.d.ts | 126 ++++++++++++++++++++++++++++ tsconfig.json | 2 +- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/types/axe-playwright/index.d.ts diff --git a/src/types/axe-playwright/index.d.ts b/src/types/axe-playwright/index.d.ts new file mode 100644 index 0000000..0a91b15 --- /dev/null +++ b/src/types/axe-playwright/index.d.ts @@ -0,0 +1,126 @@ +import { Page } from 'playwright'; +import { + AxeResults, + ElementContext, + Result, + RunOptions, + Spec, + ImpactValue, + Locale, + Rule, + Check +} from 'axe-core'; + +export interface NodeViolation { + target: string; + html: string; + violations: string; +} + +export interface Aggregate { + [key: string]: { + target: string; + html: string; + violations: number[]; + }; +} + +export interface Reporter { + report(violations: Result[]): Promise; +} + +export interface axeOptionsConfig { + axeOptions?: RunOptions; +} + +export interface ConfigOptions { + branding?: { + brand?: string; + application?: string; + }; + reporter?: 'v1' | 'v2' | 'no-passes'; + checks?: Check[]; + rules?: Rule[]; + locale?: Locale; + axeVersion?: string; +} + +export type AxeOptions = { + includedImpacts?: ImpactValue[]; + detailedReport?: boolean; + detailedReportOptions?: { html?: boolean }; + verbose?: boolean; +} & axeOptionsConfig; + +/** + * Injects axe executable commands in the active window + * @param page Playwright Page object + */ +export function injectAxe(page: Page): Promise; +/** + * Configures axe runtime options + * @param page Playwright Page object + * @param configurationOptions Axe configuration options + */ +export function configureAxe(page: Page, configurationOptions?: ConfigOptions): Promise; +/** + * Runs axe-core tools on the relevant page and returns all results + * @param page Playwright Page object + * @param context Optional element context + * @param options Optional axe run options + */ +export function getAxeResults(page: Page, context?: ElementContext, options?: RunOptions): Promise; +/** + * Runs axe-core tools and returns all accessibility violations detected on the page + * @param page Playwright Page object + * @param context Optional element context + * @param options Optional axe run options + */ +export function getViolations(page: Page, context?: ElementContext, options?: RunOptions): Promise; +/** + * Report violations using the provided reporter + * @param violations Array of axe-core Result objects + * @param reporter Reporter instance + */ +export function reportViolations(violations: Result[], reporter: Reporter): Promise; +/** + * Performs Axe validations and reporting + * @param page Playwright Page object + * @param context Optional element context + * @param axeOptions Axe options + * @param skipFailures Whether to skip failures + * @param reporter Reporter instance or type + * @param options Additional options + */ +export function checkA11y( + page: Page, + context?: ElementContext, + axeOptions?: AxeOptions, + skipFailures?: boolean, + reporter?: Reporter | 'default' | 'html' | 'junit' | 'v2', + options?: any +): Promise; +/** + * Filters violations by impact values + * @param violations Array of axe-core Result objects + * @param includedImpacts Array of impact values to include + */ +export function getImpactedViolations( + violations: Result[], + includedImpacts?: ImpactValue[] +): Result[]; +/** + * Asserts or warns based on the presence of violations and skipFailures flag + * @param violations Array of axe-core Result objects + * @param skipFailures Whether to skip failures + */ +export function testResultDependsOnViolations( + violations: Result[], + skipFailures: boolean +): void; +/** + * Aggregates and describes violations for reporting + * @param violations Array of axe-core Result objects + * @returns Array of NodeViolation objects + */ +export function describeViolations(violations: Result[]): NodeViolation[]; diff --git a/tsconfig.json b/tsconfig.json index 70a8eba..264f5a5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "declaration": true, "rootDir": "src", "moduleResolution": "node", - "typeRoots": ["node_modules/@types"], + "typeRoots": ["node_modules/@types", "src/types"], "esModuleInterop": true, "outDir": "dist", "noImplicitAny": false, From 07a09be7e4db783c9fc265c6764cb4065ea1873b Mon Sep 17 00:00:00 2001 From: Abhinaba Ghosh Date: Fri, 12 Sep 2025 09:21:17 +0000 Subject: [PATCH 3/3] chore(types): remove obsolete axe-playwright.d.ts file --- src/types/axe-playwright.d.ts | 129 ---------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 src/types/axe-playwright.d.ts diff --git a/src/types/axe-playwright.d.ts b/src/types/axe-playwright.d.ts deleted file mode 100644 index 6c18bce..0000000 --- a/src/types/axe-playwright.d.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { Page } from 'playwright'; -import { - AxeResults, - ElementContext, - Result, - RunOptions, - Spec, - ImpactValue, - Locale, - Rule, - Check -} from 'axe-core'; - -export interface NodeViolation { - target: string; - html: string; - violations: string; -} - -export interface Aggregate { - [key: string]: { - target: string; - html: string; - violations: number[]; - }; -} - -export interface Reporter { - report(violations: Result[]): Promise; -} - -export interface axeOptionsConfig { - axeOptions?: RunOptions; -} - -export interface ConfigOptions { - branding?: { - brand?: string; - application?: string; - }; - reporter?: 'v1' | 'v2' | 'no-passes'; - checks?: Check[]; - rules?: Rule[]; - locale?: Locale; - axeVersion?: string; -} - -export type AxeOptions = { - includedImpacts?: ImpactValue[]; - detailedReport?: boolean; - detailedReportOptions?: { html?: boolean }; - verbose?: boolean; -} & axeOptionsConfig; - -/** - * Injects axe executable commands in the active window - * @param page Playwright Page object - */ -export function injectAxe(page: Page): Promise; -/** - * Configures axe runtime options - * @param page Playwright Page object - * @param configurationOptions Axe configuration options - */ -export function configureAxe(page: Page, configurationOptions?: ConfigOptions): Promise; -/** - * Runs axe-core tools on the relevant page and returns all results - * @param page Playwright Page object - * @param context Optional element context - * @param options Optional axe run options - */ -export function getAxeResults(page: Page, context?: ElementContext, options?: RunOptions): Promise; -/** - * Runs axe-core tools and returns all accessibility violations detected on the page - * @param page Playwright Page object - * @param context Optional element context - * @param options Optional axe run options - */ -export function getViolations(page: Page, context?: ElementContext, options?: RunOptions): Promise; -/** - * Report violations using the provided reporter - * @param violations Array of axe-core Result objects - * @param reporter Reporter instance - */ -export function reportViolations(violations: Result[], reporter: Reporter): Promise; -/** - * Performs Axe validations and reporting - * @param page Playwright Page object - * @param context Optional element context - * @param axeOptions Axe options - * @param skipFailures Whether to skip failures - * @param reporter Reporter instance or type - * @param options Additional options - */ -export function checkA11y( - page: Page, - context?: ElementContext, - axeOptions?: AxeOptions, - skipFailures?: boolean, - reporter?: Reporter | 'default' | 'html' | 'junit' | 'v2', - options?: any -): Promise; - -/** - * Filters violations by impact values - * @param violations Array of axe-core Result objects - * @param includedImpacts Array of impact values to include - */ -export function getImpactedViolations( - violations: Result[], - includedImpacts?: ImpactValue[] -): Result[]; - -/** - * Asserts or warns based on the presence of violations and skipFailures flag - * @param violations Array of axe-core Result objects - * @param skipFailures Whether to skip failures - */ -export function testResultDependsOnViolations( - violations: Result[], - skipFailures: boolean -): void; - -/** - * Aggregates and describes violations for reporting - * @param violations Array of axe-core Result objects - * @returns Array of NodeViolation objects - */ -export function describeViolations(violations: Result[]): NodeViolation[]; \ No newline at end of file