@surea11y/playwright 0.1.4 → 1.0.1
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 +27 -34
- package/package.json +3 -3
- package/src/A11yCoreBuilder.d.ts +7 -2
- package/src/A11yCoreBuilder.js +15 -15
- package/src/formatFailures.js +3 -4
package/README.md
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
# surea11y
|
|
1
|
+
# @surea11y/playwright
|
|
2
2
|
|
|
3
|
-
A Playwright binding for [
|
|
3
|
+
A Playwright binding for [`@surea11y/core`](https://github.com/rumoroso/surea11y-core) — scans a real, already-rendered page for accessibility issues using surea11y's DOM-rules engine.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Install (local development)
|
|
8
|
-
|
|
9
|
-
`surea11y` isn't published to npm yet, so this package depends on it via a relative `file:` path (see `package.json`):
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
"dependencies": { "surea11y": "file:../core" }
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
That means this project must stay a sibling of `surea11y` (or you update the path) for `npm install` to resolve it.
|
|
5
|
+
## Install
|
|
16
6
|
|
|
17
7
|
```bash
|
|
18
|
-
npm install
|
|
8
|
+
npm install @surea11y/playwright playwright
|
|
19
9
|
npx playwright install chromium # every test launches a real browser -- npm install alone doesn't fetch it
|
|
20
|
-
npm test
|
|
21
10
|
```
|
|
22
11
|
|
|
23
|
-
`npm test` only needs Chromium. The cross-browser regression tests in `tests/cross-browser.test.js` (proving this works against Firefox/WebKit too, not just Chromium) additionally need `npx playwright install firefox webkit`.
|
|
12
|
+
`npm test` (in this repo) only needs Chromium. The cross-browser regression tests in `tests/cross-browser.test.js` (proving this works against Firefox/WebKit too, not just Chromium) additionally need `npx playwright install firefox webkit`.
|
|
24
13
|
|
|
25
14
|
## Usage
|
|
26
15
|
|
|
27
16
|
```js
|
|
28
17
|
const { chromium } = require('playwright');
|
|
29
|
-
const { A11yCoreBuilder } = require('surea11y
|
|
18
|
+
const { A11yCoreBuilder } = require('@surea11y/playwright');
|
|
30
19
|
|
|
31
20
|
const browser = await chromium.launch();
|
|
32
21
|
const page = await browser.newPage();
|
|
@@ -44,11 +33,13 @@ console.log(results.checksResults.filter(r => r.outcome === 'fail'));
|
|
|
44
33
|
await browser.close();
|
|
45
34
|
```
|
|
46
35
|
|
|
47
|
-
`results` is surea11y's own native result shape — see [
|
|
36
|
+
`results` is `@surea11y/core`'s own native result shape — see its [`OUTPUT_SCHEMA.md`](https://github.com/rumoroso/surea11y-core/blob/main/docs/OUTPUT_SCHEMA.md) — not the `violations`/`passes`/`incomplete`/`inapplicable` shape used by other popular accessibility testing tools. The builder's *method names* are modeled on common conventions in this space for migration familiarity; the richer result schema is kept as-is.
|
|
48
37
|
|
|
49
38
|
Also see `examples/basic-scan.js` for a runnable script (`npm run example -- <url>`).
|
|
50
39
|
|
|
51
|
-
`withTags()`/`disableRules()` above have counterparts: `.withRules([...])` (only run these specific rule IDs) and `.disableTags([...])` (never run rules carrying any of these tags). All four compose the same way similar allow/deny-list options do in other accessibility testing tools, with one non-obvious rule worth knowing: a "disable" always wins over a "with" on the same ID/tag (e.g. `.withRules(['a']).disableRules(['a'])` drops `'a'` entirely), and combining `.withRules()` **and** `.withTags()` together requires a rule to satisfy *both* (surea11y's default `includeMode: 'and'`
|
|
40
|
+
`withTags()`/`disableRules()` above have counterparts: `.withRules([...])` (only run these specific rule IDs) and `.disableTags([...])` (never run rules carrying any of these tags). All four compose the same way similar allow/deny-list options do in other accessibility testing tools, with one non-obvious rule worth knowing: a "disable" always wins over a "with" on the same ID/tag (e.g. `.withRules(['a']).disableRules(['a'])` drops `'a'` entirely), and combining `.withRules()` **and** `.withTags()` together requires a rule to satisfy *both* (`@surea11y/core`'s default `includeMode: 'and'`), not either one.
|
|
41
|
+
|
|
42
|
+
`.exclude(selector)` above excludes globally. Pass a second argument to scope it to specific rule IDs instead: `.exclude('.mat-select', { rules: ['aria-required-children'] })` skips `.mat-select` for that rule only — every other rule still sees it. Global and rule-scoped `.exclude()` calls compose freely.
|
|
52
43
|
|
|
53
44
|
**Create one builder per scan.** `A11yCoreBuilder` is a mutable object with no reset between `.analyze()` calls — `include()`/`exclude()`/`withRules()`/`disableRules()`/`withTags()`/`disableTags()`/`options()`/`withCustomRules()` all push onto or merge into internal state that persists for the instance's lifetime. Calling one of them again before a second `.analyze()` call *accumulates* on top of the first scan's scope rather than replacing it (this is exactly what makes "call `.include()` several times for one scan," above, work — the same accumulation just also applies across separate scans if you reuse an instance). `.reportOnly()`/`.frames()`/`.elementRef()` are the exception: each call replaces the previous value instead of merging with it.
|
|
54
45
|
|
|
@@ -60,7 +51,7 @@ The pattern above works unchanged inside a real `@playwright/test` test (this is
|
|
|
60
51
|
|
|
61
52
|
```js
|
|
62
53
|
const { test, expect } = require('@playwright/test');
|
|
63
|
-
const { A11yCoreBuilder, formatFailures } = require('surea11y
|
|
54
|
+
const { A11yCoreBuilder, formatFailures } = require('@surea11y/playwright');
|
|
64
55
|
|
|
65
56
|
test('page has no accessibility violations', async ({ page }) => {
|
|
66
57
|
await page.goto('https://example.com/');
|
|
@@ -86,7 +77,7 @@ Error: 1) button-name-present (serious): This button has no accessible name.
|
|
|
86
77
|
Add an alt attribute (use alt="" only for decorative images).
|
|
87
78
|
```
|
|
88
79
|
|
|
89
|
-
...with Playwright's own raw diff still printed underneath (unavoidable — `toEqual` always includes it), but the readable summary now comes first, where it's actually useful. Deliberately a plain function, not a custom `expect` matcher — no dependency on any particular assertion library, so it works the same with Playwright's `expect`, Jest, Vitest, or a hand-rolled `if`/`throw`. Defaults to `fail`/`cantTell` outcomes (the only two that ever carry occurrences); pass `{ outcomes: [...] }` to narrow further. A thrown rule (`occurrences: []`, `error` set
|
|
80
|
+
...with Playwright's own raw diff still printed underneath (unavoidable — `toEqual` always includes it), but the readable summary now comes first, where it's actually useful. Deliberately a plain function, not a custom `expect` matcher — no dependency on any particular assertion library, so it works the same with Playwright's `expect`, Jest, Vitest, or a hand-rolled `if`/`throw`. Defaults to `fail`/`cantTell` outcomes (the only two that ever carry occurrences); pass `{ outcomes: [...] }` to narrow further. A thrown rule (`occurrences: []`, `error` set) is still surfaced using its `error` message rather than silently dropped.
|
|
90
81
|
|
|
91
82
|
### Scanning every frame, including cross-origin iframes
|
|
92
83
|
|
|
@@ -99,11 +90,11 @@ for (const frame of results.frames) {
|
|
|
99
90
|
}
|
|
100
91
|
```
|
|
101
92
|
|
|
102
|
-
Unlike script-injection-based accessibility tools (which need a `postMessage`-based protocol to reach cross-origin iframes, since they're injected as a plain `<script>` fully subject to the browser's same-origin policy), this needs no
|
|
93
|
+
Unlike script-injection-based accessibility tools (which need a `postMessage`-based protocol to reach cross-origin iframes, since they're injected as a plain `<script>` fully subject to the browser's same-origin policy), this needs no extra engine support at all — Playwright drives every frame via CDP at the automation-process level, so cross-origin `frame.evaluate()` already just works. Default off, so plain `.analyze()` is unaffected unless you opt in.
|
|
103
94
|
|
|
104
95
|
### Trimming the result to just violations
|
|
105
96
|
|
|
106
|
-
By default `analyze()` returns every rule's outcome, including `pass`/`notApplicable` — surea11y's own deliberate "not a violations-only list" design
|
|
97
|
+
By default `analyze()` returns every rule's outcome, including `pass`/`notApplicable` — `@surea11y/core`'s own deliberate "not a violations-only list" design. Use `.reportOnly()` to post-filter down to only the outcomes you care about:
|
|
107
98
|
|
|
108
99
|
```js
|
|
109
100
|
const results = await new A11yCoreBuilder({ page })
|
|
@@ -113,7 +104,7 @@ const results = await new A11yCoreBuilder({ page })
|
|
|
113
104
|
console.log(results.checksResults); // only fail/cantTell entries, pass/notApplicable dropped
|
|
114
105
|
```
|
|
115
106
|
|
|
116
|
-
Valid outcome values are `'pass'`, `'fail'`, `'cantTell'`, `'notApplicable'`. This is pure binding-layer filtering —
|
|
107
|
+
Valid outcome values are `'pass'`, `'fail'`, `'cantTell'`, `'notApplicable'`. This is pure binding-layer filtering — the engine itself still computes every rule; nothing about the scan itself changes. Combines with `.frames(true)`: the filter is applied to `results.topFrame` and each entry of `results.frames` independently.
|
|
117
108
|
|
|
118
109
|
### Getting a live element handle, not just a selector string
|
|
119
110
|
|
|
@@ -133,7 +124,7 @@ Each `ElementHandle` holds a browser-side reference until garbage collected or e
|
|
|
133
124
|
|
|
134
125
|
### Registering a custom rule at runtime
|
|
135
126
|
|
|
136
|
-
|
|
127
|
+
`@surea11y/core` supports registering additional rules per-scan via `engineOptions.customRules`. Use `.withCustomRules()` to register one:
|
|
137
128
|
|
|
138
129
|
```js
|
|
139
130
|
const results = await new A11yCoreBuilder({ page })
|
|
@@ -150,7 +141,7 @@ const results = await new A11yCoreBuilder({ page })
|
|
|
150
141
|
.analyze();
|
|
151
142
|
```
|
|
152
143
|
|
|
153
|
-
A custom rule descriptor is the same shape as one of surea11y's own internal rule modules (`{ id, meta, runInPage, applicability?, data? }`) — see
|
|
144
|
+
A custom rule descriptor is the same shape as one of `@surea11y/core`'s own internal rule modules (`{ id, meta, runInPage, applicability?, data? }`) — see its [`ENGINE_OPTIONS.md`](https://github.com/rumoroso/surea11y-core/blob/main/docs/ENGINE_OPTIONS.md) for the full contract. Results appear in `checksResults` exactly like a built-in rule's, including automatic `selector`/`html`/`structuralPath` fill-in. Registered per-scan only (nothing persists between calls or shows up in any catalog listing), and a custom rule whose `id` collides with a built-in one overrides it for that scan.
|
|
154
145
|
|
|
155
146
|
Pass an array to register several at once, or call `.withCustomRules()` again to add more — like `.withRules()`/`.withTags()`, it accumulates rather than replacing what was already registered:
|
|
156
147
|
|
|
@@ -161,24 +152,26 @@ const results = await new A11yCoreBuilder({ page })
|
|
|
161
152
|
.analyze();
|
|
162
153
|
```
|
|
163
154
|
|
|
164
|
-
**Why `.withCustomRules()` instead of the raw `.options({ customRules })` passthrough** (still supported, and composes with this method if you use both): `runInPage`/`applicability` must reach the page as a function-source *string*, not a live `Function` — a Playwright `page.evaluate()` argument crosses a JSON boundary that can't carry a live function reference, only a string surea11y can reconstruct with `new Function` on the page side. Passing a raw live function via `.options()` directly would silently fail to serialize; `.withCustomRules()` calls `.toString()` on a live function for you, so you can write a normal function and not have to remember that constraint yourself. A string is still accepted as-is if you already have one.
|
|
155
|
+
**Why `.withCustomRules()` instead of the raw `.options({ customRules })` passthrough** (still supported, and composes with this method if you use both): `runInPage`/`applicability` must reach the page as a function-source *string*, not a live `Function` — a Playwright `page.evaluate()` argument crosses a JSON boundary that can't carry a live function reference, only a string `@surea11y/core` can reconstruct with `new Function` on the page side. Passing a raw live function via `.options()` directly would silently fail to serialize; `.withCustomRules()` calls `.toString()` on a live function for you, so you can write a normal function and not have to remember that constraint yourself. A string is still accepted as-is if you already have one.
|
|
165
156
|
|
|
166
|
-
Invalid input (a missing/empty `id`, or a `runInPage`/`applicability` that's neither a function nor a non-empty string) throws immediately from `.withCustomRules()` itself, rather than surfacing later as a silently-skipped rule deep inside the page — easier to catch during development. (Note: a *raw* `.options({ customRules })` call bypasses this check entirely and defers to surea11y's own engine-side behavior, which silently skips an invalid descriptor rather than throwing
|
|
157
|
+
Invalid input (a missing/empty `id`, or a `runInPage`/`applicability` that's neither a function nor a non-empty string) throws immediately from `.withCustomRules()` itself, rather than surfacing later as a silently-skipped rule deep inside the page — easier to catch during development. (Note: a *raw* `.options({ customRules })` call bypasses this check entirely and defers to `@surea11y/core`'s own engine-side behavior, which silently skips an invalid descriptor rather than throwing.)
|
|
167
158
|
|
|
168
159
|
### Element addressing beyond a CSS selector
|
|
169
160
|
|
|
170
|
-
Every occurrence already carries `selector` and (with `.elementRef(true)`, above) a live `ElementHandle`. It also carries `structuralPath` — a sibling-index path from the document root down to the flagged element (e.g. `[1, 0, 2]`) — a more robust identity than a selector string alone, since it survives some DOM changes a selector wouldn't (an id/class rename, for instance). No opt-in needed; it's already on every `fail`/`cantTell` occurrence today. See
|
|
161
|
+
Every occurrence already carries `selector` and (with `.elementRef(true)`, above) a live `ElementHandle`. It also carries `structuralPath` — a sibling-index path from the document root down to the flagged element (e.g. `[1, 0, 2]`) — a more robust identity than a selector string alone, since it survives some DOM changes a selector wouldn't (an id/class rename, for instance). No opt-in needed; it's already on every `fail`/`cantTell` occurrence today. See [`OUTPUT_SCHEMA.md`](https://github.com/rumoroso/surea11y-core/blob/main/docs/OUTPUT_SCHEMA.md) for the full field description.
|
|
171
162
|
|
|
172
163
|
## TypeScript
|
|
173
164
|
|
|
174
|
-
`src/A11yCoreBuilder.d.ts` (re-exported from `src/index.d.ts`, wired up via `package.json`'s `types` field) ships hand-written types for the whole builder API plus surea11y's native result shapes (`A11yCoreResult`, `CheckResult`, `Occurrence`, `CompositeResult`, etc.)
|
|
165
|
+
`src/A11yCoreBuilder.d.ts` (re-exported from `src/index.d.ts`, wired up via `package.json`'s `types` field) ships hand-written types for the whole builder API plus `@surea11y/core`'s native result shapes (`A11yCoreResult`, `CheckResult`, `Occurrence`, `CompositeResult`, etc.). `analyze()` is typed `Promise<A11yCoreResult | A11yCoreMultiFrameResult>` — narrow on `'topFrame' in results` (or cast, if you already know which mode you called) to get the specific shape back, since a fluent builder can't statically track that `.frames(true)` was called earlier in the chain. `playwright` is a `peerDependencies` entry (not just `devDependencies`) since the class's `page` argument and `Occurrence#elementHandle` both come from it — consumers need their own `playwright` install for the types to resolve, same as they already do to construct a `Page` in the first place.
|
|
175
166
|
|
|
176
167
|
## Building another framework binding?
|
|
177
168
|
|
|
178
|
-
See
|
|
169
|
+
See `@surea11y/core`'s [`BINDING_AUTHORS_GUIDE.md`](https://github.com/rumoroso/surea11y-core/blob/main/docs/BINDING_AUTHORS_GUIDE.md) — a reference for building a new binding, covering which parity features are engine-level (work through a generic `.options()`/`runOnly` passthrough with zero binding code, including WCAG-version tag filtering) vs. binding-layer (element refs, `reportOnly`-style verbosity filtering, the `page.evaluate()` serialization-boundary caveat that `.withCustomRules()` exists to paper over).
|
|
170
|
+
|
|
171
|
+
`A11yCoreBuilder` here extends `A11yCoreBuilderBase` from [`@surea11y/binding-base`](https://github.com/rumoroso/surea11y-core-binding-base), a small shared package holding the scaffolding common to every framework binding. A new binding should depend on that package from the start.
|
|
179
172
|
|
|
180
|
-
|
|
173
|
+
## License
|
|
181
174
|
|
|
182
|
-
|
|
175
|
+
MIT — see [`LICENSE`](./LICENSE).
|
|
183
176
|
|
|
184
|
-
|
|
177
|
+
This package depends on [`@surea11y/core`](https://github.com/rumoroso/surea11y-core), which is MPL-2.0. MPL-2.0's copyleft is file-level and applies only to `@surea11y/core`'s own source files; consuming it as a normal package dependency doesn't affect this package's license.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surea11y/playwright",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Playwright binding for surea11y -- scan real, live-rendered pages for accessibility issues.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@surea11y/core": "^1.
|
|
30
|
-
"@surea11y/binding-base": "^1.
|
|
29
|
+
"@surea11y/core": "^1.1.0",
|
|
30
|
+
"@surea11y/binding-base": "^1.1.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"playwright": ">=1.0.0"
|
package/src/A11yCoreBuilder.d.ts
CHANGED
|
@@ -170,8 +170,13 @@ export class A11yCoreBuilder {
|
|
|
170
170
|
|
|
171
171
|
/** Scope the scan to one region. Call multiple times for a multi-region union. */
|
|
172
172
|
include(selector: string): this;
|
|
173
|
-
/**
|
|
174
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Skip elements matching this selector anywhere in the scanned scope.
|
|
175
|
+
* With `opts.rules`, scopes the exclusion to just the named rule ID(s)
|
|
176
|
+
* instead of globally -- on top of, not instead of, any global exclusions
|
|
177
|
+
* from other `.exclude(selector)` calls.
|
|
178
|
+
*/
|
|
179
|
+
exclude(selector: string, opts?: { rules?: string | string[] }): this;
|
|
175
180
|
/** Only run rules carrying at least one of these tags. */
|
|
176
181
|
withTags(tags: string | string[]): this;
|
|
177
182
|
/** Never run rules carrying any of these tags (applied after withTags). */
|
package/src/A11yCoreBuilder.js
CHANGED
|
@@ -14,15 +14,15 @@ const { A11yCoreBuilderBase } = require('@surea11y/binding-base');
|
|
|
14
14
|
* .options({ contrast: { mode: 'auditorAssist' } })
|
|
15
15
|
* .analyze();
|
|
16
16
|
*
|
|
17
|
-
* `results` is surea11y's own native result shape (checksResults /
|
|
18
|
-
* rulesResults -- see
|
|
17
|
+
* `results` is @surea11y/core's own native result shape (checksResults /
|
|
18
|
+
* rulesResults -- see ../core/docs/OUTPUT_SCHEMA.md), not the
|
|
19
19
|
* violations/passes/incomplete/inapplicable shape used by other tools in
|
|
20
20
|
* this space. Method names are modeled on common conventions in this space
|
|
21
21
|
* for migration ease, but the richer native schema (severity, confidence,
|
|
22
22
|
* occurrences, policy contract, WCAG SC mappings) is kept as-is rather than
|
|
23
23
|
* reshaped to match.
|
|
24
24
|
*
|
|
25
|
-
* Extends `A11yCoreBuilderBase` (from
|
|
25
|
+
* Extends `A11yCoreBuilderBase` (from `@surea11y/binding-base`), which owns
|
|
26
26
|
* every method with no driver-specific work at all -- `include()`/
|
|
27
27
|
* `exclude()`/`withTags()`/`disableTags()`/`withRules()`/`disableRules()`/
|
|
28
28
|
* `options()`/`reportOnly()`/`elementRef()`/`frames()`/`withCustomRules()`'s
|
|
@@ -32,7 +32,7 @@ const { A11yCoreBuilderBase } = require('@surea11y/binding-base');
|
|
|
32
32
|
* that are genuinely Playwright-specific: `analyze()`'s injection mechanics
|
|
33
33
|
* (including the single-argument `page.evaluate()` wrapper below), frame
|
|
34
34
|
* traversal, and `_attachElementRefs()`. See
|
|
35
|
-
* `../
|
|
35
|
+
* `../binding-base/README.md` for what's shared and why.
|
|
36
36
|
*
|
|
37
37
|
* Opt in to scanning every frame on the page (including cross-origin
|
|
38
38
|
* iframes) via .frames(true):
|
|
@@ -44,17 +44,17 @@ const { A11yCoreBuilderBase } = require('@surea11y/binding-base');
|
|
|
44
44
|
* Unlike script-injection-based accessibility engines (which need a
|
|
45
45
|
* postMessage-based protocol, runPartial/finishRun, to reach cross-origin
|
|
46
46
|
* iframes, since they're injected as a plain <script> and are fully subject
|
|
47
|
-
* to the browser's same-origin policy), this doesn't need any surea11y
|
|
47
|
+
* to the browser's same-origin policy), this doesn't need any @surea11y/core
|
|
48
48
|
* engine support: Playwright
|
|
49
49
|
* drives every frame via CDP at the automation-process level, not as
|
|
50
50
|
* in-page script, so cross-origin frame.evaluate() already just works --
|
|
51
|
-
* verified empirically
|
|
51
|
+
* verified empirically.
|
|
52
52
|
* Default off, so plain .analyze() keeps returning the single native result
|
|
53
53
|
* object it always has.
|
|
54
54
|
*
|
|
55
55
|
* By default `analyze()` returns every rule's outcome, including
|
|
56
|
-
* `pass`/`notApplicable` -- surea11y's own deliberate "not a
|
|
57
|
-
* violations-only list" design (see
|
|
56
|
+
* `pass`/`notApplicable` -- @surea11y/core's own deliberate "not a
|
|
57
|
+
* violations-only list" design (see ../core/docs/OUTPUT_SCHEMA.md).
|
|
58
58
|
* Opt in to a lighter payload with `.reportOnly(['fail', 'cantTell'])`,
|
|
59
59
|
* which post-filters `checksResults` by `outcome` (applied per-frame when
|
|
60
60
|
* combined with `.frames(true)`, since `checksResults` lives at
|
|
@@ -74,12 +74,12 @@ const { A11yCoreBuilderBase } = require('@surea11y/binding-base');
|
|
|
74
74
|
* await firstFail.occurrences[0].elementHandle.screenshot({ path: 'flagged.png' });
|
|
75
75
|
*
|
|
76
76
|
* Register your own rule(s) for just this scan with
|
|
77
|
-
* `.withCustomRules([...])` (surea11y's `engineOptions.customRules`
|
|
78
|
-
* escape hatch -- see
|
|
77
|
+
* `.withCustomRules([...])` (@surea11y/core's `engineOptions.customRules`
|
|
78
|
+
* escape hatch -- see ../core/docs/ENGINE_OPTIONS.md). Pass a real,
|
|
79
79
|
* live `runInPage`/
|
|
80
80
|
* `applicability` function -- unlike the raw `.options({ customRules })`
|
|
81
81
|
* passthrough, this method converts them to the function-source string
|
|
82
|
-
* surea11y needs on this side of the page.evaluate() JSON boundary for
|
|
82
|
+
* @surea11y/core needs on this side of the page.evaluate() JSON boundary for
|
|
83
83
|
* you, so you don't have to remember to call .toString() yourself:
|
|
84
84
|
*
|
|
85
85
|
* const results = await new A11yCoreBuilder({ page })
|
|
@@ -119,8 +119,8 @@ class A11yCoreBuilder extends A11yCoreBuilderBase {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* Runs the scan and returns surea11y's native result object.
|
|
123
|
-
* @returns {Promise<object>} see
|
|
122
|
+
* Runs the scan and returns @surea11y/core's native result object.
|
|
123
|
+
* @returns {Promise<object>} see ../core/docs/OUTPUT_SCHEMA.md
|
|
124
124
|
*/
|
|
125
125
|
async analyze() {
|
|
126
126
|
const { contextSelector, engineOptions, runOnly } = this._buildEngineArgs();
|
|
@@ -129,13 +129,13 @@ class A11yCoreBuilder extends A11yCoreBuilderBase {
|
|
|
129
129
|
// signature) only accepts ONE arg value -- page.evaluate(fn, a, b, c, d)
|
|
130
130
|
// throws "Too many arguments. If you need to pass more than 1 argument
|
|
131
131
|
// to the function wrap them in an object." (confirmed against a real
|
|
132
|
-
// Playwright page -- see
|
|
132
|
+
// Playwright page -- see ../core/docs/INTEGRATION.md for the
|
|
133
133
|
// full story, including why this differs from Puppeteer's variadic
|
|
134
134
|
// form). runa11yCoreInPage itself takes 4 positional args, so wrap it in
|
|
135
135
|
// a single-arg function that destructures one options object, embedding
|
|
136
136
|
// runa11yCoreInPage's own source via .toString() so the wrapper stays
|
|
137
137
|
// fully self-contained once serialized into the page (it has zero free
|
|
138
|
-
// vars of its own -- see
|
|
138
|
+
// vars of its own -- see ../core/docs/RULE_AUTHORING.md for why that
|
|
139
139
|
// matters).
|
|
140
140
|
const wrapperSource = `(args) => {
|
|
141
141
|
const runa11yCoreInPage = ${runa11yCoreInPage.toString()};
|
package/src/formatFailures.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// Re-exported from surea11y
|
|
3
|
+
// Re-exported from @surea11y/binding-base, which now holds the single
|
|
4
4
|
// canonical copy shared across every surea11y binding -- see
|
|
5
|
-
// ../
|
|
6
|
-
// ../surea11y-binding-base/README.md for the full rationale. Kept as a
|
|
5
|
+
// ../binding-base/README.md for the full rationale. Kept as a
|
|
7
6
|
// real file here (not just re-exporting straight from src/index.js) so
|
|
8
|
-
// `require('surea11y
|
|
7
|
+
// `require('@surea11y/playwright/src/formatFailures')` keeps working for
|
|
9
8
|
// anyone importing the submodule path directly.
|
|
10
9
|
const { formatFailures } = require('@surea11y/binding-base');
|
|
11
10
|
|