testaro 14.5.1 → 14.6.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/README.md +1 -1
- package/package.json +1 -1
- package/tests/nuVal.js +14 -7
package/README.md
CHANGED
|
@@ -532,7 +532,7 @@ The `ibm` tool is one of two tools (`testaro` is the other) with a `withItems` p
|
|
|
532
532
|
|
|
533
533
|
The `nuVal` tool performs the tests of the Nu Html Checker.
|
|
534
534
|
|
|
535
|
-
Its `rules` argument is **not** an array of rule IDs, but instead is an array of rule _specifications_. A rule specification for `nuVal` is a string with the format `
|
|
535
|
+
Its `rules` argument is **not** an array of rule IDs, but instead is an array of rule _specifications_. A rule specification for `nuVal` is a string with the format `=ruleID` or `~ruleID`. The `=` prefix indicates that the rule ID is invariable. The `~` prefix indicates that the rule ID is variable, in which case the `ruleID` part of the specification is a matching regular expression, rather than the exact text of a message. This `rules` format arises from the fact that `nuVal` generates customized messages and does not accompany them with rule identifiers.
|
|
536
536
|
|
|
537
537
|
###### QualWeb
|
|
538
538
|
|
package/package.json
CHANGED
package/tests/nuVal.js
CHANGED
|
@@ -60,17 +60,24 @@ exports.reporter = async (page, options) => {
|
|
|
60
60
|
fetchOptions.body = page[1];
|
|
61
61
|
const nuResult = await fetch(nuURL, fetchOptions);
|
|
62
62
|
const nuData = await nuResult.json();
|
|
63
|
-
const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
|
|
64
63
|
// Delete left and right quotation marks and their erratic invalid replacements.
|
|
64
|
+
const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
|
|
65
65
|
data[page[0]] = nuDataClean;
|
|
66
|
-
// If there is a report and
|
|
66
|
+
// If there is a report and rules were specified:
|
|
67
67
|
if (! data[page[0]].error && rules && Array.isArray(rules) && rules.length) {
|
|
68
68
|
// Remove all messages except those specified.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
data[page[0]].messages = data[page[0]].messages.filter(message => rules.some(rule => {
|
|
70
|
+
if (rule[0] === '=') {
|
|
71
|
+
return message.message === rule.slice(1);
|
|
72
|
+
}
|
|
73
|
+
else if (rule[0] === '~') {
|
|
74
|
+
return new RegExp(rule.slice(1)).test(message.message);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(`ERROR: Invalid nuVal rule ${rule}`);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
catch (error) {
|