testaro 57.2.0 → 57.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "57.2.0",
3
+ "version": "57.4.0",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -54,7 +54,7 @@ const doTestAct = async () => {
54
54
  // Get the saved report.
55
55
  const reportJSON = await fs.readFile(reportPath, 'utf8');
56
56
  const report = JSON.parse(reportJSON);
57
- // Get the act.
57
+ // Get a reference to the act in the report.
58
58
  const act = report.acts[actIndex];
59
59
  // Get the tool name.
60
60
  const {which} = act;
@@ -94,7 +94,7 @@ const doTestAct = async () => {
94
94
  act.data = actReport.data;
95
95
  act.result = actReport.result;
96
96
  // If the tool reported that the page prevented testing:
97
- if (actReport.data && actReport.data.prevented) {
97
+ if (act.data && act.data.prevented) {
98
98
  // Add prevention data to the job data.
99
99
  report.jobData.preventions[which] = act.data.error;
100
100
  }
@@ -118,8 +118,19 @@ const doTestAct = async () => {
118
118
  }
119
119
  // Otherwise, i.e. if the page does not exist:
120
120
  else {
121
+ // Add data to the act.
122
+ act.data ??= {};
123
+ act.data.prevented = true;
124
+ act.data.error = 'No page';
125
+ // Add prevention data to the job data.
126
+ report.jobData.preventions[which] = act.data.error;
127
+ // Save the revised report.
128
+ const reportJSON = JSON.stringify(report);
129
+ await fs.writeFile(reportPath, reportJSON);
121
130
  // Report this.
122
- process.send('ERROR: No page');
131
+ const message = 'ERROR: No page';
132
+ console.log(message);
133
+ process.send(message);
123
134
  }
124
135
  }
125
136
  };
package/run.js CHANGED
@@ -174,7 +174,7 @@ const goTo = async (report, page, url, timeout, waitUntil) => {
174
174
  // Otherwise, if the response status was rejection of excessive requests:
175
175
  else if (httpStatus === 429) {
176
176
  // Return this.
177
- console.log(`Visit to ${url} prevented by request frequency restriction (status 429)`);
177
+ console.log(`ERROR: Visit to ${url} prevented by request frequency limit (status 429)`);
178
178
  return {
179
179
  success: false,
180
180
  error: 'status429'
@@ -356,15 +356,15 @@ const launch = exports.launch = async (report, debug, waits, tempBrowserID, temp
356
356
  }
357
357
  // Otherwise, i.e. if the launch or navigation failed:
358
358
  else {
359
- // Report this and nullify the page.
360
- addError(true, true, report, actIndex, `ERROR: Launch failed (${navResult.error})`);
359
+ // Report this.
360
+ addError(true, false, report, actIndex, `ERROR: Launch failed (${navResult.error})`);
361
361
  page = null;
362
362
  }
363
363
  }
364
364
  // If an error occurred:
365
365
  catch(error) {
366
366
  // Report this.
367
- addError(true, true, report, actIndex, `ERROR launching or navigating ${error.message}`);
367
+ addError(true, false, report, actIndex, `ERROR launching or navigating ${error.message}`);
368
368
  page = null;
369
369
  };
370
370
  }
@@ -633,8 +633,9 @@ const doActs = async (report) => {
633
633
  // If this failed:
634
634
  if (page.prevented) {
635
635
  // Add this to the act.
636
- act.prevented = true;
637
- act.error = page.error || '';
636
+ act.data ??= {};
637
+ act.data.prevented = true;
638
+ act.data.error = page.error || '';
638
639
  }
639
640
  }
640
641
  // Otherwise, if the act is a test act:
@@ -708,8 +709,9 @@ const doActs = async (report) => {
708
709
  // If this failed:
709
710
  if (page.prevented) {
710
711
  // Add this to the act.
711
- act.prevented = true;
712
- act.error = page.error || '';
712
+ act.data ??= {};
713
+ act.data.prevented = true;
714
+ act.data.error = page.error || '';
713
715
  }
714
716
  // Otherwise, i.e. if it succeeded:
715
717
  else {
@@ -782,14 +784,14 @@ const doActs = async (report) => {
782
784
  act.result.url = page.url();
783
785
  // If a prohibited redirection occurred:
784
786
  if (response.exception === 'badRedirection') {
785
- // Report this and abort the job.
786
- addError(true, true, report, actIndex, 'ERROR: Navigation illicitly redirected');
787
+ // Report this.
788
+ addError(true, false, report, actIndex, 'ERROR: Navigation illicitly redirected');
787
789
  }
788
790
  }
789
791
  // Otherwise, i.e. if the visit failed:
790
792
  else {
791
- // Report this and abort the job.
792
- addError(true, true, report, actIndex, 'ERROR: Visit failed');
793
+ // Report this.
794
+ addError(true, false, report, actIndex, 'ERROR: Visit failed');
793
795
  }
794
796
  }
795
797
  // Otherwise, if the act is a wait for text:
@@ -871,7 +873,7 @@ const doActs = async (report) => {
871
873
  .catch(async error => {
872
874
  // Report this and abort the job.
873
875
  console.log(`ERROR waiting for page to be ${act.which} (${error.message})`);
874
- addError(true, true, report, actIndex, `ERROR waiting for page to be ${act.which}`);
876
+ addError(true, false, report, actIndex, `ERROR waiting for page to be ${act.which}`);
875
877
  });
876
878
  // If the wait succeeded:
877
879
  if (actIndex > -2) {
@@ -1015,7 +1017,7 @@ const doActs = async (report) => {
1015
1017
  // If the move fails:
1016
1018
  catch(error) {
1017
1019
  // Add the error result to the act and abort the job.
1018
- addError(true, true, report, actIndex, `ERROR: ${move} failed`);
1020
+ addError(true, false, report, actIndex, `ERROR: ${move} failed`);
1019
1021
  }
1020
1022
  if (act.result.success) {
1021
1023
  try {
@@ -1349,19 +1351,19 @@ const doActs = async (report) => {
1349
1351
  // Otherwise, i.e. if the act type is unknown:
1350
1352
  else {
1351
1353
  // Add the error result to the act and abort the job.
1352
- addError(true, true, report, actIndex, 'ERROR: Invalid act type');
1354
+ addError(true, false, report, actIndex, 'ERROR: Invalid act type');
1353
1355
  }
1354
1356
  }
1355
1357
  // Otherwise, a page URL is required but does not exist, so:
1356
1358
  else {
1357
1359
  // Add an error result to the act and abort the job.
1358
- addError(true, true, report, actIndex, 'ERROR: Page has no URL');
1360
+ addError(true, false, report, actIndex, 'ERROR: Page has no URL');
1359
1361
  }
1360
1362
  }
1361
1363
  // Otherwise, i.e. if no page exists:
1362
1364
  else {
1363
1365
  // Add an error result to the act and abort the job.
1364
- addError(true, true, report, actIndex, 'ERROR: No page identified');
1366
+ addError(true, false, report, actIndex, 'ERROR: No page identified');
1365
1367
  }
1366
1368
  // Add the end time to the act.
1367
1369
  act.endTime = Date.now();
package/tests/ed11y.js CHANGED
@@ -187,10 +187,12 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
187
187
  };
188
188
  }
189
189
  // Return the data and result, discarding the separate element data.
190
+ const data = {};
191
+ if (result.prevented) {
192
+ data.prevented = true;
193
+ }
190
194
  return {
191
- data: {
192
- prevented: result.prevented
193
- },
195
+ data,
194
196
  result
195
197
  };
196
198
  }
@@ -198,12 +200,8 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
198
200
  else {
199
201
  // Return this.
200
202
  return {
201
- data: {
202
- prevented: false
203
- },
204
- result: {
205
- prevented: false,
206
- }
203
+ data: {},
204
+ result: {}
207
205
  }
208
206
  }
209
207
  };