axe-playwright
Advanced tools
Comparing version 1.1.12 to 1.2.1
import { Page } from 'playwright'; | ||
import { AxeResults, ElementContext, Result, RunOptions } from 'axe-core'; | ||
import DefaultTerminalReporter from './reporter/defaultTerminalReporter'; | ||
import Reporter, { ConfigOptions, Options } from './types'; | ||
import Reporter, { ConfigOptions, AxeOptions } from './types'; | ||
import { Options } from 'axe-html-reporter'; | ||
declare global { | ||
@@ -49,7 +50,8 @@ interface Window { | ||
* @param context | ||
* @param options | ||
* @param axeOptions | ||
* @param skipFailures | ||
* @param reporter | ||
* @param options | ||
*/ | ||
export declare const checkA11y: (page: Page, context?: ElementContext | undefined, options?: Options | undefined, skipFailures?: boolean, reporter?: Reporter | 'default' | 'v2') => Promise<void>; | ||
export declare const checkA11y: (page: Page, context?: ElementContext | undefined, axeOptions?: AxeOptions | undefined, skipFailures?: boolean, reporter?: Reporter | 'default' | 'v2', options?: Options | undefined) => Promise<void>; | ||
export { DefaultTerminalReporter }; |
@@ -44,2 +44,3 @@ "use strict"; | ||
const terminalReporterV2_1 = __importDefault(require("./reporter/terminalReporterV2")); | ||
const axe_html_reporter_1 = require("axe-html-reporter"); | ||
/** | ||
@@ -100,16 +101,22 @@ * Injects axe executable commands in the active window | ||
* @param context | ||
* @param options | ||
* @param axeOptions | ||
* @param skipFailures | ||
* @param reporter | ||
* @param options | ||
*/ | ||
const checkA11y = (page, context = undefined, options = undefined, skipFailures = false, reporter = 'default') => __awaiter(void 0, void 0, void 0, function* () { | ||
const checkA11y = (page, context = undefined, axeOptions = undefined, skipFailures = false, reporter = 'default', options = undefined) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b, _c; | ||
const violations = yield (0, exports.getViolations)(page, context, options === null || options === void 0 ? void 0 : options.axeOptions); | ||
const impactedViolations = (0, utils_1.getImpactedViolations)(violations, options === null || options === void 0 ? void 0 : options.includedImpacts); | ||
const violations = yield (0, exports.getViolations)(page, context, axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.axeOptions); | ||
if (violations.length > 0) { | ||
yield (0, axe_html_reporter_1.createHtmlReport)({ results: { violations }, options }); | ||
} | ||
else | ||
console.log("There were no violations to save in report"); | ||
const impactedViolations = (0, utils_1.getImpactedViolations)(violations, axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.includedImpacts); | ||
let reporterWithOptions; | ||
if (reporter === 'default') { | ||
reporterWithOptions = new defaultTerminalReporter_1.default(options === null || options === void 0 ? void 0 : options.detailedReport, (_a = options === null || options === void 0 ? void 0 : options.detailedReportOptions) === null || _a === void 0 ? void 0 : _a.html, (_b = options === null || options === void 0 ? void 0 : options.verbose) !== null && _b !== void 0 ? _b : true); | ||
reporterWithOptions = new defaultTerminalReporter_1.default(axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.detailedReport, (_a = axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.detailedReportOptions) === null || _a === void 0 ? void 0 : _a.html, (_b = axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.verbose) !== null && _b !== void 0 ? _b : true); | ||
} | ||
else if (reporter === 'v2') { | ||
reporterWithOptions = new terminalReporterV2_1.default((_c = options === null || options === void 0 ? void 0 : options.verbose) !== null && _c !== void 0 ? _c : false); | ||
reporterWithOptions = new terminalReporterV2_1.default((_c = axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.verbose) !== null && _c !== void 0 ? _c : false); | ||
} | ||
@@ -116,0 +123,0 @@ else { |
@@ -38,3 +38,3 @@ import { Result, Check, ImpactValue, Locale, Rule, RunOptions } from 'axe-core'; | ||
} | ||
export type Options = { | ||
export type AxeOptions = { | ||
includedImpacts?: ImpactValue[]; | ||
@@ -41,0 +41,0 @@ detailedReport?: boolean; |
{ | ||
"name": "axe-playwright", | ||
"version": "1.1.12", | ||
"version": "1.2.1", | ||
"description": "Custom Playwright commands to inject axe-core and test for a11y", | ||
@@ -44,3 +44,4 @@ "main": "dist/index.js", | ||
"picocolors": "^1.0.0", | ||
"axe-core": "^4.5.1" | ||
"axe-core": "^4.5.1", | ||
"axe-html-reporter": "2.2.3" | ||
}, | ||
@@ -47,0 +48,0 @@ "repository": { |
@@ -98,3 +98,3 @@ ![logo](./docs/logo.png) | ||
##### options (optional) | ||
##### axeOptions (optional) | ||
@@ -130,2 +130,7 @@ Set of options passed into rules or checks, temporarily modifying them. This contrasts with axe.configure, which is more permanent. | ||
##### options (dedicated for axe-html-reporter) | ||
Options dedicated for HTML reporter. | ||
[axe-html-reporter](https://www.npmjs.com/package/axe-html-reporter) | ||
### getAxeResults | ||
@@ -285,4 +290,32 @@ | ||
#### HTML Report | ||
Thanks to [axe-html-reporter](https://www.npmjs.com/package/axe-html-reporter) you can generate HTML report(s). | ||
From default HTML file(s) will be generated under `/artifacts/accessibilityReport.html`. | ||
Report's options can customized from `checkAlly` level: | ||
``` | ||
await checkA11y( | ||
page, | ||
'form', | ||
{ | ||
axeOptions: { | ||
runOnly: { | ||
type: 'tag', | ||
values: ['wcag2a'], | ||
}, | ||
}, | ||
}, | ||
true, 'default', | ||
{ | ||
outputDirPath: 'results', | ||
outputDir: 'accessibility', | ||
reportFileName: 'accessibility-audit.html' | ||
} | ||
) | ||
``` | ||
## Before you Go | ||
If it works for you , leave a [Star](https://github.com/abhinaba-ghosh/axe-playwright)! :star: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31315
423
319
0
4
+ Addedaxe-html-reporter@2.2.3
+ Addedaxe-html-reporter@2.2.3(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmustache@4.2.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)