@axe-core/playwright 4.8.2-a80add3.0 → 4.8.2-b07d38c.0

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.
Files changed (2) hide show
  1. package/dist/index.d.mts +101 -0
  2. package/package.json +8 -7
@@ -0,0 +1,101 @@
1
+ import { SerialFrameSelector, RunOptions, AxeResults } from 'axe-core';
2
+ import { Page } from 'playwright-core';
3
+
4
+ interface AxePlaywrightParams {
5
+ page: Page;
6
+ axeSource?: string;
7
+ }
8
+
9
+ declare class AxeBuilder {
10
+ private page;
11
+ private includes;
12
+ private excludes;
13
+ private option;
14
+ private source;
15
+ private legacyMode;
16
+ private errorUrl;
17
+ constructor({ page, axeSource }: AxePlaywrightParams);
18
+ /**
19
+ * Selector to include in analysis.
20
+ * This may be called any number of times.
21
+ * @param String selector
22
+ * @returns this
23
+ */
24
+ include(selector: SerialFrameSelector): this;
25
+ /**
26
+ * Selector to exclude in analysis.
27
+ * This may be called any number of times.
28
+ * @param String selector
29
+ * @returns this
30
+ */
31
+ exclude(selector: SerialFrameSelector): this;
32
+ /**
33
+ * Set options to be passed into axe-core
34
+ * @param RunOptions options
35
+ * @returns AxeBuilder
36
+ */
37
+ options(options: RunOptions): this;
38
+ /**
39
+ * Limit analysis to only the specified rules.
40
+ * Cannot be used with `AxeBuilder#withTags`
41
+ * @param String|Array rules
42
+ * @returns this
43
+ */
44
+ withRules(rules: string | string[]): this;
45
+ /**
46
+ * Limit analysis to only specified tags.
47
+ * Cannot be used with `AxeBuilder#withRules`
48
+ * @param String|Array tags
49
+ * @returns this
50
+ */
51
+ withTags(tags: string | string[]): this;
52
+ /**
53
+ * Set the list of rules to skip when running an analysis.
54
+ * @param String|Array rules
55
+ * @returns this
56
+ */
57
+ disableRules(rules: string | string[]): this;
58
+ /**
59
+ * Use frameMessenger with <same_origin_only>
60
+ *
61
+ * This disables use of axe.runPartial() which is called in each frame, and
62
+ * axe.finishRun() which is called in a blank page. This uses axe.run() instead,
63
+ * but with the restriction that cross-origin frames will not be tested.
64
+ */
65
+ setLegacyMode(legacyMode?: boolean): this;
66
+ /**
67
+ * Perform analysis and retrieve results. *Does not chain.*
68
+ * @return Promise<Result | Error>
69
+ */
70
+ analyze(): Promise<AxeResults>;
71
+ /**
72
+ * Injects `axe-core` into all frames.
73
+ * @param Page - playwright page object
74
+ * @returns Promise<void>
75
+ */
76
+ private inject;
77
+ /**
78
+ * Get axe-core source and configurations
79
+ * @returns String
80
+ */
81
+ private script;
82
+ private runLegacy;
83
+ /**
84
+ * Inject `axe-core` into each frame and run `axe.runPartial`.
85
+ * Because we need to inject axe into all frames all at once
86
+ * (to avoid any potential problems with the DOM becoming out-of-sync)
87
+ * but also need to not process results for any child frames if the parent
88
+ * frame throws an error (requirements of the data structure for `axe.finishRun`),
89
+ * we have to return a deeply nested array of Promises and then flatten
90
+ * the array once all Promises have finished, throwing out any nested Promises
91
+ * if the parent Promise is not fulfilled.
92
+ * @param frame - playwright frame object
93
+ * @param context - axe-core context object
94
+ * @returns Promise<AxePartialRunner>
95
+ */
96
+ private runPartialRecursive;
97
+ private finishRun;
98
+ private axeConfigure;
99
+ }
100
+
101
+ export { AxeBuilder, AxeBuilder as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axe-core/playwright",
3
- "version": "4.8.2-a80add3.0+a80add3",
3
+ "version": "4.8.2-b07d38c.0+b07d38c",
4
4
  "description": "Provides a method to inject and analyze web pages using axe",
5
5
  "contributors": [
6
6
  {
@@ -43,7 +43,9 @@
43
43
  "prebuild": "rimraf dist",
44
44
  "build": "tsup src/index.ts --dts --format esm,cjs",
45
45
  "test": "mocha --timeout 60000 -r ts-node/register 'test/**.spec.ts'",
46
+ "test:export": "npm run test:esm && npm run test:commonjs",
46
47
  "test:esm": "node test/esmTest.mjs",
48
+ "test:commonjs": "node test/commonjsTest.js",
47
49
  "coverage": "nyc npm run test",
48
50
  "prepare": "npx playwright install && npm run build"
49
51
  },
@@ -55,17 +57,16 @@
55
57
  "@types/chai": "^4.3.3",
56
58
  "@types/express": "^4.17.14",
57
59
  "@types/mocha": "^10.0.0",
58
- "@types/node": "^18.8.3",
59
- "@types/test-listen": "^1.1.0",
60
+ "@types/node": "^20.8.10",
61
+ "async-listen": "^3.0.1",
60
62
  "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1",
61
63
  "chai": "^4.3.6",
62
64
  "express": "^4.18.2",
63
65
  "mocha": "^10.0.0",
64
66
  "nyc": "^15.1.0",
65
- "rimraf": "^3.0.2",
66
- "test-listen": "^1.1.0",
67
+ "rimraf": "^5.0.5",
67
68
  "ts-node": "^10.9.1",
68
- "tsup": "^6.7.0",
69
+ "tsup": "^7.2.0",
69
70
  "typescript": "^4.8.4"
70
71
  },
71
72
  "peerDependencies": {
@@ -90,5 +91,5 @@
90
91
  "functions": 100,
91
92
  "lines": 95
92
93
  },
93
- "gitHead": "a80add38be2b35bdc4be146f6bea7269c5c88324"
94
+ "gitHead": "b07d38cc2d85c6127391686482abf762758dce34"
94
95
  }