Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axe-playwright

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axe-playwright - npm Package Compare versions

Comparing version 1.1.12 to 1.2.1

8

dist/index.d.ts
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:
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc