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 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 `type:substring`, where `type` is replaced with a message type (namely `info` or `error`) and `substring` is replaced with any substring of a message. This `rules` format arises from the fact that `nuVal` generates customized messages and does not accompany them with rule identifiers. Thus, by choosing a type and a substring, you are deciding that any message of that type that includes that substring will be deemed a `nuVal` rule.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "14.5.1",
3
+ "version": "14.6.0",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
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 restrictions on the report messages were specified:
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
- const ruleSpecs = rules.map(ruleSpec => ruleSpec.split(':', 2));
70
- data[page[0]].messages = data[page[0]].messages.filter(message => ruleSpecs.some(
71
- ruleSpec => message.type === ruleSpec[0]
72
- && message.message.includes(ruleSpec[1])
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) {