testaro 22.0.0 → 23.0.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 +27 -15
- package/actSpecs.js +4 -3
- package/dirWatch.js +1 -1
- package/package.json +1 -1
- package/procs/nav.js +220 -0
- package/procs/testaro.js +2 -2
- package/procs/visChange.js +1 -0
- package/run.js +494 -684
- package/testaro/bulk.js +7 -4
- package/tests/testaro.js +10 -8
- /package/{standardize.js → procs/standardize.js} +0 -0
package/testaro/bulk.js
CHANGED
|
@@ -19,15 +19,18 @@ exports.reporter = async page => {
|
|
|
19
19
|
const visiblesLoc = await page.locator('body :visible');
|
|
20
20
|
const visibleLocs = await visiblesLoc.all();
|
|
21
21
|
data.visibleElements = visibleLocs.length;
|
|
22
|
-
const
|
|
22
|
+
const severity = Math.min(4, Math.round(data.visibleElements / 400));
|
|
23
|
+
const totals = [0, 0, 0, 0];
|
|
24
|
+
if (severity) {
|
|
25
|
+
totals[severity - 1] = 1;
|
|
26
|
+
}
|
|
23
27
|
return {
|
|
24
28
|
data,
|
|
25
|
-
totals
|
|
29
|
+
totals,
|
|
26
30
|
standardInstances: data.visibleElements < 200 ? [] : [{
|
|
27
31
|
ruleID: 'bulk',
|
|
28
32
|
what: 'Page contains a large number of visible elements',
|
|
29
|
-
|
|
30
|
-
ordinalSeverity: 0,
|
|
33
|
+
ordinalSeverity: severity - 1,
|
|
31
34
|
tagName: 'HTML',
|
|
32
35
|
id: '',
|
|
33
36
|
location: {
|
package/tests/testaro.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
This test implements the Testaro evaluative rules.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// CONSTANTS
|
|
6
|
+
// ######## CONSTANTS
|
|
7
7
|
|
|
8
8
|
const evalRules = {
|
|
9
9
|
allCaps: 'leaf elements with entirely upper-case text longer than 7 characters',
|
|
@@ -72,11 +72,11 @@ exports.reporter = async (page, options) => {
|
|
|
72
72
|
&& rules.slice(1).every(rule => evalRules[rule] || etcRules[rule])
|
|
73
73
|
) {
|
|
74
74
|
// For each rule invoked:
|
|
75
|
-
const
|
|
75
|
+
const calledRules = rules[0] === 'y'
|
|
76
76
|
? rules.slice(1)
|
|
77
77
|
: Object.keys(evalRules).filter(ruleID => ! rules.slice(1).includes(ruleID));
|
|
78
78
|
const testTimes = [];
|
|
79
|
-
for (const rule of
|
|
79
|
+
for (const rule of calledRules) {
|
|
80
80
|
// Initialize an argument array.
|
|
81
81
|
const ruleArgs = [page, withItems];
|
|
82
82
|
// If the rule has extra arguments:
|
|
@@ -93,17 +93,19 @@ exports.reporter = async (page, options) => {
|
|
|
93
93
|
console.log(`>>>>>> ${rule} (${what})`);
|
|
94
94
|
try {
|
|
95
95
|
const startTime = Date.now();
|
|
96
|
-
const
|
|
96
|
+
const ruleReport = await require(`../testaro/${rule}`).reporter(... ruleArgs);
|
|
97
|
+
// Add data from the test to the result.
|
|
97
98
|
const endTime = Date.now();
|
|
98
99
|
testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
|
|
99
|
-
Object.keys(
|
|
100
|
-
data.rules[rule][key] =
|
|
101
|
-
|
|
100
|
+
Object.keys(ruleReport).forEach(key => {
|
|
101
|
+
data.rules[rule][key] = ruleReport[key];
|
|
102
|
+
data.rules[rule].totals = data.rules[rule].totals.map(total => Math.round(total));
|
|
103
|
+
if (ruleReport.prevented) {
|
|
102
104
|
data.preventions.push(rule);
|
|
103
105
|
}
|
|
104
106
|
});
|
|
105
107
|
// If testing is to stop after a failure and the page failed the test:
|
|
106
|
-
if (stopOnFail &&
|
|
108
|
+
if (stopOnFail && ruleReport.totals.some(total => total)) {
|
|
107
109
|
// Stop testing.
|
|
108
110
|
break;
|
|
109
111
|
}
|
|
File without changes
|