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.
- package/package.json +1 -1
- package/tests/nuVal.js +25 -7
package/package.json
CHANGED
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
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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;
|