testaro 60.18.1 → 60.18.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tests/nuVal.js +25 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "60.18.1",
3
+ "version": "60.18.2",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests/nuVal.js CHANGED
@@ -42,7 +42,7 @@ exports.reporter = async (page, report, actIndex) => {
42
42
  }
43
43
  };
44
44
  const result = {};
45
- // If it was not obtained:
45
+ // If the source was not obtained:
46
46
  if (sourceData.prevented) {
47
47
  // Report this.
48
48
  data.prevented = true;
@@ -63,13 +63,29 @@ exports.reporter = async (page, report, actIndex) => {
63
63
  // For each page type:
64
64
  for (const page of pageTypes) {
65
65
  try {
66
- // Get a Nu Html Checker report on it.
67
66
  fetchOptions.body = page[1];
67
+ // Get a Nu Html Checker report on it.
68
68
  const nuResult = await fetch(nuURL, fetchOptions);
69
- const nuData = await nuResult.json();
70
- // Delete left and right quotation marks and their erratic invalid replacements.
71
- const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
72
- result[page[0]] = nuDataClean;
69
+ // If the request failed:
70
+ if (! nuResult.ok) {
71
+ // Get the response body as text.
72
+ const text = await nuResult.text();
73
+ // Add a failure report to the data.
74
+ result[page[0]] = {
75
+ prevented: true,
76
+ error: `HTTP ${nuResult.status}: ${nuResult.statusText}`,
77
+ rawBody: text
78
+ };
79
+ data.docTypes[page[0]] = result[page[0]];
80
+ }
81
+ // Otherwise, i.e. if it succeeded:
82
+ else {
83
+ // Get the response body as JSON.
84
+ const nuData = await nuResult.json();
85
+ // Delete left and right quotation marks and their erratic invalid replacements.
86
+ const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
87
+ result[page[0]] = nuDataClean;
88
+ }
73
89
  // If there is a report and rules were specified:
74
90
  if (! result[page[0]].error && rules && Array.isArray(rules) && rules.length) {
75
91
  // Remove all messages except those specified.
@@ -87,8 +103,10 @@ exports.reporter = async (page, report, actIndex) => {
87
103
  }));
88
104
  }
89
105
  }
106
+ // If an error occurred:
90
107
  catch (error) {
91
- const message = `ERROR getting results for ${page[0]} (${error.message})`;
108
+ // Report it.
109
+ const message = `ERROR getting results for ${page[0]} (${error.message}; status ${nuResult.status}, body ${JSON.stringify(nuResult?.body, null, 2)}`;
92
110
  console.log(message);
93
111
  data.docTypes[page[0]].prevented = true;
94
112
  data.docTypes[page[0]].error = message;