pa11y-ci-reporter-runner 4.1.0 → 4.1.2
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 +69 -26
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# Pa11y CI Reporter Runner
|
|
2
2
|
|
|
3
|
-
Pa11y CI Reporter Runner
|
|
3
|
+
Pa11y CI Reporter Runner facilitates testing of
|
|
4
|
+
[Pa11y CI reporters](https://github.com/pa11y/pa11y-ci#write-a-custom-reporter).
|
|
5
|
+
Given a Pa11y CI JSON results file and optional configuration it performs the
|
|
6
|
+
Pa11y CI calls to the reporter, including proper transformation of results and
|
|
7
|
+
configuration data. Functionally, it's an emulation of the Pa11y CI side of the
|
|
8
|
+
reporter interface with explicit control over execution of each step.
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
7
|
-
Install Pa11y CI Reporter Runner via
|
|
12
|
+
Install Pa11y CI Reporter Runner via
|
|
13
|
+
[npm](https://www.npmjs.com/package/pa11y-ci-reporter-runner).
|
|
8
14
|
|
|
9
15
|
```sh
|
|
10
16
|
npm install pa11y-ci-reporter-runner
|
|
@@ -12,16 +18,22 @@ npm install pa11y-ci-reporter-runner
|
|
|
12
18
|
|
|
13
19
|
## Usage
|
|
14
20
|
|
|
15
|
-
Pa11y CI Reporter Runner exports a factory function `createRunner` that creates
|
|
21
|
+
Pa11y CI Reporter Runner exports a factory function `createRunner` that creates
|
|
22
|
+
a reporter runner. This function takes four arguments:
|
|
16
23
|
|
|
17
24
|
- `resultsFileName`: Path to a Pa11y CI JSON results file.
|
|
18
|
-
- `reporterName`: Name of the reporter to execute. Can be an npm module
|
|
19
|
-
|
|
20
|
-
- `
|
|
25
|
+
- `reporterName`: Name of the reporter to execute. Can be an npm module, for
|
|
26
|
+
example `pa11y-ci-reporter-html`, or a path to a reporter file.
|
|
27
|
+
- `options`: Optional
|
|
28
|
+
[reporter options](https://github.com/pa11y/pa11y-ci#reporter-options).
|
|
29
|
+
- `config`: Optional Pa11y CI configuration file that produces the Pa11y CI
|
|
30
|
+
JSON results.
|
|
21
31
|
|
|
22
|
-
### Runner
|
|
32
|
+
### Runner states
|
|
23
33
|
|
|
24
|
-
Pa11y CI Reporter Runner emulates calls from Pa11y CI to the given reporter for
|
|
34
|
+
Pa11y CI Reporter Runner emulates calls from Pa11y CI to the given reporter for
|
|
35
|
+
the given results file. There are five distinct states for the runner, as shown
|
|
36
|
+
below:
|
|
25
37
|
|
|
26
38
|
```mermaid
|
|
27
39
|
%% It's unfortunate that mermaid charts don't render on npmjs.com,
|
|
@@ -35,36 +47,63 @@ flowchart LR;
|
|
|
35
47
|
```
|
|
36
48
|
|
|
37
49
|
- `init`: The initial state of the runner.
|
|
38
|
-
- `beforeAll`: In this state the runner calls the reporter `beforeAll`
|
|
39
|
-
|
|
40
|
-
- `
|
|
50
|
+
- `beforeAll`: In this state the runner calls the reporter `beforeAll`
|
|
51
|
+
function.
|
|
52
|
+
- `beginUrl`: In this state the runner calls the reporter `begin` function for
|
|
53
|
+
a given URL.
|
|
54
|
+
- `urlResults`: In this state the runner calls the reporter `results` or
|
|
55
|
+
`error` function depending on the result for that URL. If there are
|
|
56
|
+
subsequent URLs, the runner next moves to `beginUrl` for the next URL. If
|
|
57
|
+
this is the last URL, the runner moves to `afterAll`.
|
|
41
58
|
- `afterAll`: In this state the runner calls the reporter `afterAll` function.
|
|
42
59
|
|
|
43
|
-
When calling reporter functions, the runner transforms the Pa11y CI results and
|
|
60
|
+
When calling reporter functions, the runner transforms the Pa11y CI results and
|
|
61
|
+
configuration data to provide the appropriate arguments. For example, the
|
|
62
|
+
`results` function is called with the results as returned from Pa11y (slightly
|
|
63
|
+
different than those returned from Pa11y CI) and the consolidated configuration
|
|
64
|
+
for the analysis of that URL.
|
|
44
65
|
|
|
45
66
|
The runner state can be obtained via the following runner functions:
|
|
46
67
|
|
|
47
68
|
- `getCurrentState()`: The current state of the runner.
|
|
48
|
-
- `getNextState()`: The next state of the runner (
|
|
69
|
+
- `getNextState()`: The next state of the runner (that is, the state that would
|
|
70
|
+
be obtained by calling the `runNext()` function).
|
|
49
71
|
|
|
50
72
|
Both functions return an object with the following properties:
|
|
51
73
|
|
|
52
|
-
- `state`: The current runner state (any state value shown
|
|
53
|
-
- `url`: The current URL for any state with an applicable URL (`beginUrl` and
|
|
74
|
+
- `state`: The current runner state (any state value shown previously)
|
|
75
|
+
- `url`: The current URL for any state with an applicable URL (`beginUrl` and
|
|
76
|
+
`urlResults`), otherwise `undefined`.
|
|
54
77
|
|
|
55
|
-
### Runner
|
|
78
|
+
### Runner execution
|
|
56
79
|
|
|
57
80
|
The reporter runner has five control functions:
|
|
58
81
|
|
|
59
|
-
- `runAll()`: Simulates Pa11y CI running the analysis from the provided JSON
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- `
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
- `runAll()`: Simulates Pa11y CI running the analysis from the provided JSON
|
|
83
|
+
results file from the current state through the end, calling all associated
|
|
84
|
+
reporter functions.
|
|
85
|
+
- `runNext()`: Simulates Pa11y CI running through the next state from the
|
|
86
|
+
provided JSON results file, calling the associated reporter function as noted
|
|
87
|
+
previously.
|
|
88
|
+
- `runUntil(targetState, targetUrl)`: Simulates Pa11y CI running the analysis
|
|
89
|
+
from the provided JSON results file from the current state through the
|
|
90
|
+
specified state/URL, calling the associated reporter functions as noted
|
|
91
|
+
above. An error is thrown if the end of the results are reached and the
|
|
92
|
+
target wasn't found. This function takes the following arguments:
|
|
93
|
+
- `targetState`: The target state of the runner (any state noted previously
|
|
94
|
+
except `init`, or any valid value of the `RunnerStates` enum).
|
|
95
|
+
- `targetUrl`: An optional target URL. If no URL is specified, the runner
|
|
96
|
+
stops at the first instance of the target state.
|
|
97
|
+
- `runUntilNext(targetState, targetUrl)`: Provides the same capability as
|
|
98
|
+
`runUntil`, but execution ends at the state prior to the target state/URL,
|
|
99
|
+
so that the target would execute if `runNext()` is subsequently called.
|
|
100
|
+
- `reset()`: Resets the runner to the `init` state and re-initializes the
|
|
101
|
+
reporter. This can be sent from any state.
|
|
102
|
+
|
|
103
|
+
These command are all asynchronous and must be completed before another is
|
|
104
|
+
sent, otherwise an error is thrown. In addition, once a run has been completed
|
|
105
|
+
and the runner is in the `afterAll` state it must be `reset` before accepting
|
|
106
|
+
any run command.
|
|
68
107
|
|
|
69
108
|
### Example
|
|
70
109
|
|
|
@@ -129,4 +168,8 @@ test('test reporter at urlResults state', async () => {
|
|
|
129
168
|
|
|
130
169
|
## Limitations
|
|
131
170
|
|
|
132
|
-
When passing config to `results`, `error`, and `afterAll`, Pa11y CI Reporter
|
|
171
|
+
When passing config to `results`, `error`, and `afterAll`, Pa11y CI Reporter
|
|
172
|
+
Runner includes the same properties as Pa11y CI except the `browser` property
|
|
173
|
+
(with the `puppeteer` `browser` object used by Pa11y CI). If the `browser`
|
|
174
|
+
object is needed, testing should be done with Pa11y CI to ensure proper
|
|
175
|
+
`browser` capabilities are available.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pa11y-ci-reporter-runner",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "Pa11y CI Reporter Runner is designed to facilitate testing of Pa11y CI reporters. Given a Pa11y CI JSON results file and optional configuration it simulates the Pa11y CI calls to the reporter.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://gitlab.com/gitlab-ci-utils/pa11y-ci-reporter-runner",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@aarongoldenthal/eslint-config-standard": "^
|
|
45
|
-
"eslint": "^8.
|
|
44
|
+
"@aarongoldenthal/eslint-config-standard": "^27.0.1",
|
|
45
|
+
"eslint": "^8.57.0",
|
|
46
46
|
"jest": "^29.7.0",
|
|
47
47
|
"jest-junit": "^16.0.0",
|
|
48
|
-
"markdownlint-cli2": "^0.
|
|
48
|
+
"markdownlint-cli2": "^0.13.0",
|
|
49
49
|
"pa11y-ci-reporter-cli-summary": "^3.0.0",
|
|
50
|
-
"prettier": "^3.
|
|
51
|
-
"tsd": "^0.
|
|
52
|
-
"typescript": "^5.
|
|
50
|
+
"prettier": "^3.2.5",
|
|
51
|
+
"tsd": "^0.31.0",
|
|
52
|
+
"typescript": "^5.4.4"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
|
-
"xstate": "^5.
|
|
56
|
+
"xstate": "^5.10.0"
|
|
57
57
|
}
|
|
58
58
|
}
|