axe-playwright 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/reporter/junitReporter.js +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
# Axe-Playwright
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+

|
|
6
7
|
[](https://www.npmjs.com/package/axe-playwright)
|
|
7
8
|
[](https://www.npmjs.com/package/axe-playwright)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Axe-core® is a powerful accessibility testing engine provided by Deque Systems that powers this package. Axe-Playwright provides simple commands to integrate the axe-core® library with your [Playwright](https://www.npmjs.com/package/playwright) tests. This integration functions seamlessly across all Playwright browsers: Chromium, Firefox, and WebKit.
|
|
11
|
+
|
|
12
|
+
Axe-core® is a trademark of [Deque Systems, Inc.](https://www.deque.com/) in the US and other countries. This project is not formally affiliated with Deque, but we are big fans! Axe-core® is used here with permission.
|
|
10
13
|
|
|
11
14
|
## Install and configure
|
|
12
15
|
|
|
@@ -22,7 +25,7 @@ npm i -D axe-playwright
|
|
|
22
25
|
npm i -D playwright
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
NOTE: axe-core® is now bundled and doesn't need to be installed separately.
|
|
26
29
|
|
|
27
30
|
### Add Typings
|
|
28
31
|
|
|
@@ -39,7 +42,7 @@ npm i -D playwright
|
|
|
39
42
|
|
|
40
43
|
### injectAxe
|
|
41
44
|
|
|
42
|
-
This will inject the
|
|
45
|
+
This will inject the axe-core® runtime into the page under test. You must run this after a call to page.goto() and before you run the checkA11y command.
|
|
43
46
|
|
|
44
47
|
You run this command with `injectAxe()` either in your test, or in a `beforeEach`, as long as the `visit` comes first.
|
|
45
48
|
|
package/dist/index.d.ts
CHANGED
|
@@ -52,5 +52,5 @@ export declare const reportViolations: (violations: Result[], reporter: Reporter
|
|
|
52
52
|
* @param reporter
|
|
53
53
|
* @param options
|
|
54
54
|
*/
|
|
55
|
-
export declare const checkA11y: (page: Page, context?: ElementContext | undefined, axeOptions?: AxeOptions | undefined, skipFailures?: boolean, reporter?: Reporter |
|
|
55
|
+
export declare const checkA11y: (page: Page, context?: ElementContext | undefined, axeOptions?: AxeOptions | undefined, skipFailures?: boolean, reporter?: Reporter | "default" | "html" | "junit" | "v2", options?: Options | undefined) => Promise<void>;
|
|
56
56
|
export { DefaultTerminalReporter };
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,9 @@ const path = __importStar(require("path"));
|
|
|
49
49
|
* @param page
|
|
50
50
|
*/
|
|
51
51
|
const injectAxe = (page) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const axe = fs.readFileSync(require.resolve('axe-core/axe.min.js'),
|
|
52
|
+
const axe = fs.readFileSync(require.resolve('axe-core/axe.min.js'), {
|
|
53
|
+
encoding: 'utf8',
|
|
54
|
+
});
|
|
53
55
|
yield page.evaluate((axe) => window.eval(axe), axe);
|
|
54
56
|
});
|
|
55
57
|
exports.injectAxe = injectAxe;
|
|
@@ -58,7 +60,7 @@ exports.injectAxe = injectAxe;
|
|
|
58
60
|
* @param page
|
|
59
61
|
* @param configurationOptions
|
|
60
62
|
*/
|
|
61
|
-
const configureAxe = (
|
|
63
|
+
const configureAxe = (page_1, ...args_1) => __awaiter(void 0, [page_1, ...args_1], void 0, function* (page, configurationOptions = {}) {
|
|
62
64
|
yield page.evaluate((configOptions) => window.axe.configure(configOptions), configurationOptions);
|
|
63
65
|
});
|
|
64
66
|
exports.configureAxe = configureAxe;
|
|
@@ -104,7 +106,7 @@ exports.reportViolations = reportViolations;
|
|
|
104
106
|
* @param reporter
|
|
105
107
|
* @param options
|
|
106
108
|
*/
|
|
107
|
-
const checkA11y = (page, context = undefined, axeOptions = undefined, skipFailures = false, reporter = 'default', options = undefined)
|
|
109
|
+
const checkA11y = (page_1, ...args_1) => __awaiter(void 0, [page_1, ...args_1], void 0, function* (page, context = undefined, axeOptions = undefined, skipFailures = false, reporter = 'default', options = undefined) {
|
|
108
110
|
var _a, _b, _c;
|
|
109
111
|
const violations = yield (0, exports.getViolations)(page, context, axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.axeOptions);
|
|
110
112
|
const impactedViolations = (0, utils_1.getImpactedViolations)(violations, axeOptions === null || axeOptions === void 0 ? void 0 : axeOptions.includedImpacts);
|
|
@@ -46,8 +46,8 @@ class JUnitReporter {
|
|
|
46
46
|
this.outputFilename = outputFilename;
|
|
47
47
|
}
|
|
48
48
|
report(violations) {
|
|
49
|
-
var _a;
|
|
50
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a;
|
|
51
51
|
let lineBreak = '\n';
|
|
52
52
|
let pageUrl = ((_a = this.page) === null || _a === void 0 ? void 0 : _a.url()) || 'Page';
|
|
53
53
|
let suite = junit_report_builder_1.default.testSuite().name(pageUrl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axe-playwright",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Custom Playwright commands to inject axe-core and test for a11y",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"author": "Abhinaba Ghosh",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "^
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"jest": "^
|
|
35
|
-
"jest-each": "^
|
|
36
|
-
"jest-playwright-preset": "^
|
|
37
|
-
"playwright": "^1.
|
|
38
|
-
"prettier": "^
|
|
39
|
-
"ts-jest": "^
|
|
40
|
-
"typescript": "^
|
|
32
|
+
"@types/jest": "^29.5.13",
|
|
33
|
+
"@types/node": "^22.7.2",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"jest-each": "^29.7.0",
|
|
36
|
+
"jest-playwright-preset": "^4.0.0",
|
|
37
|
+
"playwright": "^1.47.2",
|
|
38
|
+
"prettier": "^3.3.3",
|
|
39
|
+
"ts-jest": "^29.2.5",
|
|
40
|
+
"typescript": "^5.6.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@types/junit-report-builder": "^3.0.
|
|
44
|
-
"axe-core": "^4.
|
|
45
|
-
"axe-html-reporter": "2.2.
|
|
46
|
-
"junit-report-builder": "^
|
|
47
|
-
"picocolors": "^1.
|
|
43
|
+
"@types/junit-report-builder": "^3.0.2",
|
|
44
|
+
"axe-core": "^4.10.0",
|
|
45
|
+
"axe-html-reporter": "2.2.11",
|
|
46
|
+
"junit-report-builder": "^5.1.1",
|
|
47
|
+
"picocolors": "^1.1.0"
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|