pa11y-ci-reporter-runner 2.0.2 → 2.0.4
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/index.js +25 -21
- package/lib/config.js +1 -1
- package/lib/formatter.js +3 -2
- package/lib/pa11yci-service.js +35 -32
- package/lib/reporter-builder.js +6 -5
- package/lib/runner-states.js +1 -1
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -18,9 +18,10 @@ const RunnerStates = require('./lib/runner-states');
|
|
|
18
18
|
/**
|
|
19
19
|
* Loads the Pa11y CI results from JSON file.
|
|
20
20
|
*
|
|
21
|
+
* @param {string} fileName Pa11y CI JSON results file name.
|
|
22
|
+
* @returns {object} Pa11y CI results.
|
|
23
|
+
* @throws {TypeError} Throws if fileName is not a string.
|
|
21
24
|
* @private
|
|
22
|
-
* @param {string} fileName Pa11y CI JSON results file name.
|
|
23
|
-
* @returns {object} Pa11y CI results.
|
|
24
25
|
*/
|
|
25
26
|
const loadPa11yciResults = (fileName) => {
|
|
26
27
|
if (typeof fileName !== 'string') {
|
|
@@ -40,9 +41,11 @@ const loadPa11yciResults = (fileName) => {
|
|
|
40
41
|
* or object with url and other configuration, so this return a list of just
|
|
41
42
|
* the url strings.
|
|
42
43
|
*
|
|
44
|
+
* @param {object[]} values The urls array from configuration.
|
|
45
|
+
* @returns {string[]} Array of URL strings.
|
|
46
|
+
* @throws {TypeError} Throws if URLs array contains an invalid
|
|
47
|
+
* URL element.
|
|
43
48
|
* @private
|
|
44
|
-
* @param {object[]} values The urls array from configuration.
|
|
45
|
-
* @returns {string[]} Array of URL strings.
|
|
46
49
|
*/
|
|
47
50
|
const getUrlList = (values) => {
|
|
48
51
|
const result = [];
|
|
@@ -64,9 +67,10 @@ const getUrlList = (values) => {
|
|
|
64
67
|
* may not be in the same order). URLs in config are only checked if
|
|
65
68
|
* provided. If specified and inconsistent, throws error.
|
|
66
69
|
*
|
|
70
|
+
* @param {object} results Pa11y CI JSON results file.
|
|
71
|
+
* @param {object} config Pa11y CI configuration.
|
|
72
|
+
* @throws {TypeError} Throws if config URLs do not match results URLs.
|
|
67
73
|
* @private
|
|
68
|
-
* @param {object} results Pa11y CI JSON results file.
|
|
69
|
-
* @param {object} config Pa11y CI configuration.
|
|
70
74
|
*/
|
|
71
75
|
const validateUrls = (results, config) => {
|
|
72
76
|
// Valid if no urls specified in config
|
|
@@ -88,9 +92,9 @@ const validateUrls = (results, config) => {
|
|
|
88
92
|
/**
|
|
89
93
|
* Check if the given Pa11y results are an execution error.
|
|
90
94
|
*
|
|
91
|
-
* @private
|
|
92
95
|
* @param {object} results Pa11y results for a single URL.
|
|
93
96
|
* @returns {boolean} True if the results are an execution error.
|
|
97
|
+
* @private
|
|
94
98
|
*/
|
|
95
99
|
const isError = (results) =>
|
|
96
100
|
results.length === 1 && results[0] instanceof Error;
|
|
@@ -99,13 +103,13 @@ const isError = (results) =>
|
|
|
99
103
|
* Factory to create a pa11y-ci reporter runner that can execute
|
|
100
104
|
* a reporter with the specified pa11y-ci JSON results file.
|
|
101
105
|
*
|
|
102
|
-
* @public
|
|
103
|
-
* @static
|
|
104
106
|
* @param {string} resultsFileName Pa11y CI JSON results file.
|
|
105
107
|
* @param {string} reporterName Name of the reporter to execute (module or path).
|
|
106
108
|
* @param {object} options The reporter options.
|
|
107
109
|
* @param {object} config The Pa11y CI configuration.
|
|
108
110
|
* @returns {object} A Pa11y CI reporter runner.
|
|
111
|
+
* @static
|
|
112
|
+
* @public
|
|
109
113
|
*/
|
|
110
114
|
// eslint-disable-next-line max-lines-per-function
|
|
111
115
|
const createRunner = (
|
|
@@ -123,8 +127,8 @@ const createRunner = (
|
|
|
123
127
|
* Create a new reporter with the given options and config
|
|
124
128
|
* (encapsulated as a function for consistency).
|
|
125
129
|
*
|
|
126
|
-
* @private
|
|
127
130
|
* @returns {object} The reporter associated with the runner.
|
|
131
|
+
* @private
|
|
128
132
|
*/
|
|
129
133
|
const getReporter = () =>
|
|
130
134
|
reporterBuilder.buildReporter(
|
|
@@ -149,9 +153,9 @@ const createRunner = (
|
|
|
149
153
|
/**
|
|
150
154
|
* Implements the runner beginUrl event, calling reporter.begin.
|
|
151
155
|
*
|
|
156
|
+
* @param {string} url The url being analyzed.
|
|
152
157
|
* @async
|
|
153
158
|
* @private
|
|
154
|
-
* @param {string} url The url being analyzed.
|
|
155
159
|
*/
|
|
156
160
|
const beginUrl = async (url) => {
|
|
157
161
|
await reporter.begin(url);
|
|
@@ -161,9 +165,9 @@ const createRunner = (
|
|
|
161
165
|
* Implements the runner urlResults event, calling reporter.results or
|
|
162
166
|
* reporter.error as appropriate based on the results.
|
|
163
167
|
*
|
|
168
|
+
* @param {string} url The url being analyzed.
|
|
164
169
|
* @async
|
|
165
170
|
* @private
|
|
166
|
-
* @param {string} url The url being analyzed.
|
|
167
171
|
*/
|
|
168
172
|
const urlResults = async (url) => {
|
|
169
173
|
const results = pa11yciResults.results[url];
|
|
@@ -207,9 +211,9 @@ const createRunner = (
|
|
|
207
211
|
/**
|
|
208
212
|
* Resets the runner and reporter to the initial states.
|
|
209
213
|
*
|
|
214
|
+
* @instance
|
|
210
215
|
* @async
|
|
211
216
|
* @public
|
|
212
|
-
* @instance
|
|
213
217
|
*/
|
|
214
218
|
const reset = async () => {
|
|
215
219
|
await service.reset();
|
|
@@ -219,9 +223,9 @@ const createRunner = (
|
|
|
219
223
|
/**
|
|
220
224
|
* Executes the entire Pa11y CI sequence, calling all reporter functions.
|
|
221
225
|
*
|
|
226
|
+
* @instance
|
|
222
227
|
* @async
|
|
223
228
|
* @public
|
|
224
|
-
* @instance
|
|
225
229
|
*/
|
|
226
230
|
const runAll = async () => {
|
|
227
231
|
await service.runUntil(RunnerStates.afterAll);
|
|
@@ -231,9 +235,9 @@ const createRunner = (
|
|
|
231
235
|
* Executes the next event in the Pa11y CI sequence, calling the
|
|
232
236
|
* appropriate reporter function.
|
|
233
237
|
*
|
|
238
|
+
* @instance
|
|
234
239
|
* @async
|
|
235
240
|
* @public
|
|
236
|
-
* @instance
|
|
237
241
|
*/
|
|
238
242
|
const runNext = async () => {
|
|
239
243
|
await service.runNext();
|
|
@@ -244,11 +248,11 @@ const createRunner = (
|
|
|
244
248
|
* until the specified current state and optional URL are reached. If a URL is not
|
|
245
249
|
* specified, the run completes on the first occurrence of the target state.
|
|
246
250
|
*
|
|
247
|
-
* @async
|
|
248
|
-
* @public
|
|
249
251
|
* @instance
|
|
250
252
|
* @param {string} targetState The target state to run to.
|
|
251
253
|
* @param {string} [targetUrl] The target URL to run to.
|
|
254
|
+
* @async
|
|
255
|
+
* @public
|
|
252
256
|
*/
|
|
253
257
|
const runUntil = async (targetState, targetUrl) => {
|
|
254
258
|
await service.runUntil(targetState, targetUrl);
|
|
@@ -259,11 +263,11 @@ const createRunner = (
|
|
|
259
263
|
* until the specified next state and optional URL are reached. If a URL is not
|
|
260
264
|
* specified, the run completes on the first occurrence of the target state.
|
|
261
265
|
*
|
|
262
|
-
* @async
|
|
263
|
-
* @public
|
|
264
266
|
* @instance
|
|
265
267
|
* @param {string} targetState The target state to run to.
|
|
266
268
|
* @param {string} [targetUrl] The target URL to run to.
|
|
269
|
+
* @async
|
|
270
|
+
* @public
|
|
267
271
|
*/
|
|
268
272
|
const runUntilNext = async (targetState, targetUrl) => {
|
|
269
273
|
await service.runUntilNext(targetState, targetUrl);
|
|
@@ -272,9 +276,9 @@ const createRunner = (
|
|
|
272
276
|
/**
|
|
273
277
|
* Get the current state (state, url).
|
|
274
278
|
*
|
|
275
|
-
* @public
|
|
276
279
|
* @instance
|
|
277
280
|
* @returns {object} The current state.
|
|
281
|
+
* @public
|
|
278
282
|
*/
|
|
279
283
|
// eslint-disable-next-line prefer-destructuring -- required for jsdoc
|
|
280
284
|
const getCurrentState = service.getCurrentState;
|
|
@@ -282,9 +286,9 @@ const createRunner = (
|
|
|
282
286
|
/**
|
|
283
287
|
* Get the next state (state, url).
|
|
284
288
|
*
|
|
285
|
-
* @public
|
|
286
289
|
* @instance
|
|
287
290
|
* @returns {object} The next state.
|
|
291
|
+
* @public
|
|
288
292
|
*/
|
|
289
293
|
// eslint-disable-next-line prefer-destructuring -- required for jsdoc
|
|
290
294
|
const getNextState = service.getNextState;
|
package/lib/config.js
CHANGED
|
@@ -24,9 +24,9 @@ const normalizeConfig = (config) => {
|
|
|
24
24
|
* configuration including defaults and determining the consolidated
|
|
25
25
|
* configuration for each URL.
|
|
26
26
|
*
|
|
27
|
-
* @static
|
|
28
27
|
* @param {object} config The Pa11y CI configuration.
|
|
29
28
|
* @returns {object} Config object.
|
|
29
|
+
* @static
|
|
30
30
|
*/
|
|
31
31
|
const configFactory = (config) => {
|
|
32
32
|
const { defaults, urls } = normalizeConfig(config);
|
package/lib/formatter.js
CHANGED
|
@@ -16,9 +16,9 @@ const isError = (issues) =>
|
|
|
16
16
|
* allowing JSON result files to be used for reporter interface
|
|
17
17
|
* testing. Error messages are converted to Error objects.
|
|
18
18
|
*
|
|
19
|
-
* @static
|
|
20
19
|
* @param {object} jsonResults Pa11y CI JSON results.
|
|
21
20
|
* @returns {object} The equivalent Pa11y CI object.
|
|
21
|
+
* @static
|
|
22
22
|
*/
|
|
23
23
|
const convertJsonToResultsObject = (jsonResults) => {
|
|
24
24
|
const results = {
|
|
@@ -44,10 +44,11 @@ const convertJsonToResultsObject = (jsonResults) => {
|
|
|
44
44
|
* returns a Pa11y results object of the format sent to the reporter
|
|
45
45
|
* results event. Throws if the url is not found in the results.
|
|
46
46
|
*
|
|
47
|
-
* @static
|
|
48
47
|
* @param {string} url The URL to find results for,.
|
|
49
48
|
* @param {object} results Pa11y CI results object.
|
|
50
49
|
* @returns {object} The Pa11y results object for the URL.
|
|
50
|
+
* @throws {Error} Throws if results are not found for the given URL.
|
|
51
|
+
* @static
|
|
51
52
|
*/
|
|
52
53
|
const getPa11yResultsFromPa11yCiResults = (url, results) => {
|
|
53
54
|
const issues = results.results[url];
|
package/lib/pa11yci-service.js
CHANGED
|
@@ -15,10 +15,10 @@ const finalState = RunnerStates.afterAll;
|
|
|
15
15
|
/**
|
|
16
16
|
* Enum for machine events.
|
|
17
17
|
*
|
|
18
|
-
* @enum {string}
|
|
19
|
-
* @private
|
|
20
18
|
* @readonly
|
|
19
|
+
* @enum {string}
|
|
21
20
|
* @static
|
|
21
|
+
* @private
|
|
22
22
|
*/
|
|
23
23
|
const MachineEvents = Object.freeze({
|
|
24
24
|
NEXT: 'NEXT',
|
|
@@ -28,10 +28,10 @@ const MachineEvents = Object.freeze({
|
|
|
28
28
|
/**
|
|
29
29
|
* Enum for runner service states.
|
|
30
30
|
*
|
|
31
|
-
* @enum {string}
|
|
32
|
-
* @private
|
|
33
31
|
* @readonly
|
|
32
|
+
* @enum {string}
|
|
34
33
|
* @static
|
|
34
|
+
* @private
|
|
35
35
|
*/
|
|
36
36
|
const StateTypes = Object.freeze({
|
|
37
37
|
current: 'current',
|
|
@@ -41,9 +41,9 @@ const StateTypes = Object.freeze({
|
|
|
41
41
|
/**
|
|
42
42
|
* Gets the initial pa11yci-runner state machine context given an array of URLs.
|
|
43
43
|
*
|
|
44
|
-
* @private
|
|
45
44
|
* @param {Array} urls Array of URLs.
|
|
46
45
|
* @returns {object} The initial state machine context.
|
|
46
|
+
* @private
|
|
47
47
|
*/
|
|
48
48
|
const getInitialContext = (urls) => ({
|
|
49
49
|
urlIndex: 0,
|
|
@@ -53,9 +53,9 @@ const getInitialContext = (urls) => ({
|
|
|
53
53
|
/**
|
|
54
54
|
* Checks the runner state to determine whether it has an associated URL.
|
|
55
55
|
*
|
|
56
|
-
* @private
|
|
57
56
|
* @param {string} state The state to check.
|
|
58
57
|
* @returns {boolean} True if the state has an associated url.
|
|
58
|
+
* @private
|
|
59
59
|
*/
|
|
60
60
|
const hasUrl = (state) =>
|
|
61
61
|
state === RunnerStates.beginUrl || state === RunnerStates.urlResults;
|
|
@@ -63,9 +63,9 @@ const hasUrl = (state) =>
|
|
|
63
63
|
/**
|
|
64
64
|
* Gets the URL for the given machine state.
|
|
65
65
|
*
|
|
66
|
-
* @private
|
|
67
66
|
* @param {object} machineState The machine state to check against.
|
|
68
67
|
* @returns {string} The current URL for the machine state.
|
|
68
|
+
* @private
|
|
69
69
|
*/
|
|
70
70
|
const getUrlForState = (machineState) =>
|
|
71
71
|
hasUrl(machineState.value)
|
|
@@ -75,8 +75,9 @@ const getUrlForState = (machineState) =>
|
|
|
75
75
|
/**
|
|
76
76
|
* Validates that the given state is a valid RunnerStates value. Throws if not.
|
|
77
77
|
*
|
|
78
|
+
* @param {string} state The state to validate.
|
|
79
|
+
* @throws {TypeError} Throws if state is not a valid RunnerStates value.
|
|
78
80
|
* @private
|
|
79
|
-
* @param {string} state The state to validate.
|
|
80
81
|
*/
|
|
81
82
|
const validateRunnerState = (state) => {
|
|
82
83
|
if (!Object.keys(RunnerStates).includes(state)) {
|
|
@@ -88,11 +89,11 @@ const validateRunnerState = (state) => {
|
|
|
88
89
|
* Checks if the machine state matches the targetState and either no
|
|
89
90
|
* targetUrl was specified or the context matches the targetUrl.
|
|
90
91
|
*
|
|
92
|
+
* @param {object} machineState The machine state to check against.
|
|
93
|
+
* @param {RunnerStates} targetState The target runner state.
|
|
94
|
+
* @param {string} [targetUrl] The target URL.
|
|
95
|
+
* @returns {boolean} True if the context matches the target, otherwise false.
|
|
91
96
|
* @private
|
|
92
|
-
* @param {object} machineState The machine state to check against.
|
|
93
|
-
* @param {RunnerStates} targetState The target runner state.
|
|
94
|
-
* @param {string} [targetUrl] The target URL.
|
|
95
|
-
* @returns {boolean} True if the context matches the target, otherwise false.
|
|
96
97
|
*/
|
|
97
98
|
const isAtTarget = (machineState, targetState, targetUrl) => {
|
|
98
99
|
return (
|
|
@@ -104,9 +105,9 @@ const isAtTarget = (machineState, targetState, targetUrl) => {
|
|
|
104
105
|
/**
|
|
105
106
|
* Gets a summary of the machine state (state, url).
|
|
106
107
|
*
|
|
107
|
-
* @private
|
|
108
108
|
* @param {object} machineState The machine state.
|
|
109
109
|
* @returns {object} The machine state summary.
|
|
110
|
+
* @private
|
|
110
111
|
*/
|
|
111
112
|
const getStateSummary = (machineState) => ({
|
|
112
113
|
state: machineState.value,
|
|
@@ -116,11 +117,11 @@ const getStateSummary = (machineState) => ({
|
|
|
116
117
|
/**
|
|
117
118
|
* Factory function that returns a pa11yci-runner service.
|
|
118
119
|
*
|
|
119
|
-
* @public
|
|
120
|
-
* @static
|
|
121
120
|
* @param {Array} urls Array of URLs.
|
|
122
121
|
* @param {object} actions Actions object with functions to execute for each event.
|
|
123
122
|
* @returns {object} A pa11yci-runner service.
|
|
123
|
+
* @static
|
|
124
|
+
* @public
|
|
124
125
|
*/
|
|
125
126
|
// eslint-disable-next-line max-lines-per-function
|
|
126
127
|
const serviceFactory = (urls, actions) => {
|
|
@@ -136,6 +137,8 @@ const serviceFactory = (urls, actions) => {
|
|
|
136
137
|
/**
|
|
137
138
|
* Validates that a command is allowed in the given state. Throws if invalid.
|
|
138
139
|
*
|
|
140
|
+
* @throws {Error} Throws if a previous command is still pending.
|
|
141
|
+
* @throws {Error} Throws if the runner state is afterAll (must reset first).
|
|
139
142
|
* @private
|
|
140
143
|
*/
|
|
141
144
|
const validateCommandAllowed = () => {
|
|
@@ -155,9 +158,9 @@ const serviceFactory = (urls, actions) => {
|
|
|
155
158
|
* Sends the specified event to the pa11yci-machine and executes
|
|
156
159
|
* the applicable action for that state.
|
|
157
160
|
*
|
|
161
|
+
* @param {MachineEvents} event The event name to be sent.
|
|
158
162
|
* @async
|
|
159
163
|
* @private
|
|
160
|
-
* @param {MachineEvents} event The event name to be sent.
|
|
161
164
|
*/
|
|
162
165
|
const sendEvent = async (event) => {
|
|
163
166
|
try {
|
|
@@ -188,9 +191,9 @@ const serviceFactory = (urls, actions) => {
|
|
|
188
191
|
/**
|
|
189
192
|
* Resets the service to the init state.
|
|
190
193
|
*
|
|
194
|
+
* @instance
|
|
191
195
|
* @async
|
|
192
196
|
* @public
|
|
193
|
-
* @instance
|
|
194
197
|
*/
|
|
195
198
|
const reset = async () => {
|
|
196
199
|
await sendEvent(MachineEvents.RESET);
|
|
@@ -200,9 +203,9 @@ const serviceFactory = (urls, actions) => {
|
|
|
200
203
|
* Executes the next event in the Pa11y CI sequence, calling the
|
|
201
204
|
* appropriate reporter function.
|
|
202
205
|
*
|
|
206
|
+
* @instance
|
|
203
207
|
* @async
|
|
204
208
|
* @public
|
|
205
|
-
* @instance
|
|
206
209
|
*/
|
|
207
210
|
const runNext = async () => {
|
|
208
211
|
validateCommandAllowed();
|
|
@@ -213,9 +216,9 @@ const serviceFactory = (urls, actions) => {
|
|
|
213
216
|
/**
|
|
214
217
|
* Gets the state for the given state type (current or next).
|
|
215
218
|
*
|
|
216
|
-
* @private
|
|
217
219
|
* @param {StateTypes} stateType The state type.
|
|
218
220
|
* @returns {object} The state object for teh given type.
|
|
221
|
+
* @private
|
|
219
222
|
*/
|
|
220
223
|
const getState = (stateType) =>
|
|
221
224
|
stateType === StateTypes.current ? currentState : nextState;
|
|
@@ -227,11 +230,11 @@ const serviceFactory = (urls, actions) => {
|
|
|
227
230
|
* specified state and optional URL are reached. If a URL is not specified,
|
|
228
231
|
* the run completes on the first occurrence of the target state.
|
|
229
232
|
*
|
|
233
|
+
* @param {StateTypes} stateType The state type.
|
|
234
|
+
* @param {RunnerStates} targetState The target state to run to.
|
|
235
|
+
* @param {string} [targetUrl] The target URL to run to.
|
|
230
236
|
* @async
|
|
231
237
|
* @private
|
|
232
|
-
* @param {StateTypes} stateType The state type.
|
|
233
|
-
* @param {RunnerStates} targetState The target state to run to.
|
|
234
|
-
* @param {string} [targetUrl] The target URL to run to.
|
|
235
238
|
*/
|
|
236
239
|
const runUntilInternal = async (stateType, targetState, targetUrl) => {
|
|
237
240
|
validateCommandAllowed();
|
|
@@ -260,11 +263,11 @@ const serviceFactory = (urls, actions) => {
|
|
|
260
263
|
* until the specified current state and optional URL are reached. If a URL is not
|
|
261
264
|
* specified, the run completes on the first occurrence of the target state.
|
|
262
265
|
*
|
|
266
|
+
* @instance
|
|
267
|
+
* @param {RunnerStates} targetState The target state to run to.
|
|
268
|
+
* @param {string} [targetUrl] The target URL to run to.
|
|
263
269
|
* @async
|
|
264
270
|
* @public
|
|
265
|
-
* @instance
|
|
266
|
-
* @param {RunnerStates} targetState The target state to run to.
|
|
267
|
-
* @param {string} [targetUrl] The target URL to run to.
|
|
268
271
|
*/
|
|
269
272
|
const runUntil = async (targetState, targetUrl) => {
|
|
270
273
|
await runUntilInternal(StateTypes.current, targetState, targetUrl);
|
|
@@ -275,11 +278,11 @@ const serviceFactory = (urls, actions) => {
|
|
|
275
278
|
* until the specified next state and optional URL are reached. If a URL is not
|
|
276
279
|
* specified, the run completes on the first occurrence of the target state.
|
|
277
280
|
*
|
|
281
|
+
* @instance
|
|
282
|
+
* @param {RunnerStates} targetState The target state to run to.
|
|
283
|
+
* @param {string} [targetUrl] The target URL to run to.
|
|
278
284
|
* @async
|
|
279
285
|
* @public
|
|
280
|
-
* @instance
|
|
281
|
-
* @param {RunnerStates} targetState The target state to run to.
|
|
282
|
-
* @param {string} [targetUrl] The target URL to run to.
|
|
283
286
|
*/
|
|
284
287
|
const runUntilNext = async (targetState, targetUrl) => {
|
|
285
288
|
await runUntilInternal(StateTypes.next, targetState, targetUrl);
|
|
@@ -288,18 +291,18 @@ const serviceFactory = (urls, actions) => {
|
|
|
288
291
|
/**
|
|
289
292
|
* Get the current state (state, url).
|
|
290
293
|
*
|
|
291
|
-
* @public
|
|
292
294
|
* @instance
|
|
293
|
-
* @returns
|
|
295
|
+
* @returns {object} The current state.
|
|
296
|
+
* @public
|
|
294
297
|
*/
|
|
295
298
|
const getCurrentState = () => getStateSummary(currentState);
|
|
296
299
|
|
|
297
300
|
/**
|
|
298
301
|
* Get the next state (state, url).
|
|
299
302
|
*
|
|
300
|
-
* @public
|
|
301
303
|
* @instance
|
|
302
|
-
* @returns
|
|
304
|
+
* @returns {object} The next state.
|
|
305
|
+
* @public
|
|
303
306
|
*/
|
|
304
307
|
const getNextState = () => getStateSummary(nextState);
|
|
305
308
|
|
package/lib/reporter-builder.js
CHANGED
|
@@ -7,10 +7,10 @@ const noop = () => {};
|
|
|
7
7
|
|
|
8
8
|
const loadReporter = (reporterName) => {
|
|
9
9
|
try {
|
|
10
|
-
// eslint-disable-next-line
|
|
10
|
+
// eslint-disable-next-line n/global-require
|
|
11
11
|
return require(reporterName);
|
|
12
12
|
} catch {
|
|
13
|
-
// eslint-disable-next-line
|
|
13
|
+
// eslint-disable-next-line n/global-require
|
|
14
14
|
return require(path.resolve(process.cwd(), reporterName));
|
|
15
15
|
}
|
|
16
16
|
};
|
|
@@ -20,11 +20,12 @@ const loadReporter = (reporterName) => {
|
|
|
20
20
|
* used by pa11y-ci for reporter generation. Unlike pa11y-ci, ensures a
|
|
21
21
|
* function exists for each reporter event to allow manual execution.
|
|
22
22
|
*
|
|
23
|
-
* @param {string}
|
|
23
|
+
* @param {string} reporterName Name of the reporter to execute
|
|
24
24
|
* (module or path).
|
|
25
|
-
* @param {object}
|
|
26
|
-
* @param {object}
|
|
25
|
+
* @param {object} options The reporter options.
|
|
26
|
+
* @param {object} config The Pa11y CI configuration.
|
|
27
27
|
* @returns {object} The reporter object.
|
|
28
|
+
* @throws {TypeError} Throws if reporterName is not a string.
|
|
28
29
|
*/
|
|
29
30
|
// eslint-disable-next-line sonarjs/cognitive-complexity -- allow < 10
|
|
30
31
|
const buildReporter = (reporterName, options, config) => {
|
package/lib/runner-states.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pa11y-ci-reporter-runner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://gitlab.com/gitlab-ci-utils/pa11y-ci-reporter-runner",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@aarongoldenthal/eslint-config-standard": "^
|
|
42
|
-
"eslint": "^8.
|
|
43
|
-
"jest": "^29.
|
|
44
|
-
"jest-junit": "^
|
|
41
|
+
"@aarongoldenthal/eslint-config-standard": "^19.0.1",
|
|
42
|
+
"eslint": "^8.30.0",
|
|
43
|
+
"jest": "^29.3.1",
|
|
44
|
+
"jest-junit": "^15.0.0",
|
|
45
45
|
"markdownlint-cli": "^0.32.2",
|
|
46
|
-
"pa11y-ci-reporter-cli-summary": "^2.0.
|
|
47
|
-
"prettier": "^2.
|
|
46
|
+
"pa11y-ci-reporter-cli-summary": "^2.0.2",
|
|
47
|
+
"prettier": "^2.8.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"lodash": "^4.17.21",
|
|
51
|
-
"xstate": "^4.
|
|
51
|
+
"xstate": "^4.35.1"
|
|
52
52
|
}
|
|
53
53
|
}
|