testaro 4.10.3 → 4.11.1
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/commands.js +1 -1
- package/package.json +1 -1
- package/run.js +32 -3
- package/tests/axe.js +65 -68
- package/tests/motion.js +6 -1
package/commands.js
CHANGED
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -64,10 +64,25 @@ const tenonData = {
|
|
|
64
64
|
accessToken: '',
|
|
65
65
|
requestIDs: {}
|
|
66
66
|
};
|
|
67
|
+
// Keywords in log messages indicating errors.
|
|
68
|
+
const errorWords = [
|
|
69
|
+
'failed',
|
|
70
|
+
'error',
|
|
71
|
+
'suspicious',
|
|
72
|
+
'refused',
|
|
73
|
+
'content security policy',
|
|
74
|
+
'unrecognized',
|
|
75
|
+
'requires',
|
|
76
|
+
'warning',
|
|
77
|
+
'missing',
|
|
78
|
+
'deprecated'
|
|
79
|
+
];
|
|
67
80
|
// ########## VARIABLES
|
|
68
81
|
// Facts about the current session.
|
|
69
82
|
let logCount = 0;
|
|
70
83
|
let logSize = 0;
|
|
84
|
+
let errorLogCount = 0;
|
|
85
|
+
let errorLogSize = 0;
|
|
71
86
|
let prohibitedCount = 0;
|
|
72
87
|
let visitTimeoutCount = 0;
|
|
73
88
|
let visitRejectionCount = 0;
|
|
@@ -253,12 +268,18 @@ const launch = async typeName => {
|
|
|
253
268
|
browserContext = await browser.newContext(viewport);
|
|
254
269
|
// When a page is added to the browser context:
|
|
255
270
|
browserContext.on('page', page => {
|
|
256
|
-
// Make its console messages appear in the Playwright console.
|
|
271
|
+
// Make its console messages get reported and appear in the Playwright console.
|
|
257
272
|
page.on('console', msg => {
|
|
258
273
|
const msgText = msg.text();
|
|
259
274
|
console.log(`[${msgText}]`);
|
|
275
|
+
const msgTextLC = msgText.toLowerCase();
|
|
276
|
+
const msgLength = msgText.length;
|
|
260
277
|
logCount++;
|
|
261
|
-
logSize +=
|
|
278
|
+
logSize += msgLength;
|
|
279
|
+
if (errorWords.some(word => msgTextLC.includes(word))) {
|
|
280
|
+
errorLogCount++;
|
|
281
|
+
errorLogSize += msgLength;
|
|
282
|
+
}
|
|
262
283
|
const msgLC = msgText.toLowerCase();
|
|
263
284
|
if (msgText.includes('403') && (msgLC.includes('status') || msgLC.includes('prohibited'))) {
|
|
264
285
|
prohibitedCount++;
|
|
@@ -1224,7 +1245,13 @@ const doActs = async (report, actIndex, page) => {
|
|
|
1224
1245
|
// Performs the commands in a script.
|
|
1225
1246
|
const doScript = async (report) => {
|
|
1226
1247
|
// Reinitialize the log statistics.
|
|
1227
|
-
logCount =
|
|
1248
|
+
logCount = 0;
|
|
1249
|
+
logSize = 0;
|
|
1250
|
+
errorLogCount = 0;
|
|
1251
|
+
errorLogSize = 0;
|
|
1252
|
+
prohibitedCount = 0;
|
|
1253
|
+
visitTimeoutCount = 0;
|
|
1254
|
+
visitRejectionCount = 0;
|
|
1228
1255
|
// Add the start time to the report.
|
|
1229
1256
|
const startTime = new Date();
|
|
1230
1257
|
report.startTime = startTime.toISOString().slice(0, 19);
|
|
@@ -1239,6 +1266,8 @@ const doScript = async (report) => {
|
|
|
1239
1266
|
// Add the log statistics to the report.
|
|
1240
1267
|
report.logCount = logCount;
|
|
1241
1268
|
report.logSize = logSize;
|
|
1269
|
+
report.errorLogCount = errorLogCount;
|
|
1270
|
+
report.errorLogSize = errorLogSize;
|
|
1242
1271
|
report.prohibitedCount = prohibitedCount;
|
|
1243
1272
|
report.visitTimeoutCount = visitTimeoutCount;
|
|
1244
1273
|
report.visitRejectionCount = visitRejectionCount;
|
package/tests/axe.js
CHANGED
|
@@ -3,13 +3,26 @@
|
|
|
3
3
|
This test implements the axe-core ruleset for accessibility.
|
|
4
4
|
|
|
5
5
|
The rules argument defaults to all rules; otherwise, specify an array of rule names.
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
The detailLevel argument specifies how many result categories are to be included in the
|
|
8
|
+
details. 0 = none; 1 = violations; 2 = violations and incomplete; 3 = violations, incomplete,
|
|
9
|
+
and passes; 4 = violations, incomplete, passes, and inapplicable. Regardless of the value of this
|
|
10
|
+
argument, Axe-core is instructed to report all nodes with violation or incomplete results, but only
|
|
11
|
+
1 node per rule found to be passed or inapplicable. Therefore, from the results of this test it
|
|
12
|
+
is possible to count the rules passed and the inapplicable rules, but not the nodes for which each
|
|
13
|
+
rule is passed or inapplicable. To count those nodes, one would need to revise the 'resultTypes'
|
|
14
|
+
property of the 'axeOptions' object.
|
|
15
|
+
|
|
16
|
+
The report of this test shows rule totals by result category and, within the violation and
|
|
17
|
+
incomplete categories, node totals by severity. It does not show rule or node totals by test
|
|
18
|
+
category (“tag”), such as 'wcag21aaa'. Scoring can consider test categories by getting the value
|
|
19
|
+
of the 'tags' property of each rule.
|
|
7
20
|
*/
|
|
8
21
|
// IMPORTS
|
|
9
|
-
const {injectAxe,
|
|
22
|
+
const {injectAxe, getAxeResults} = require('axe-playwright');
|
|
10
23
|
// FUNCTIONS
|
|
11
24
|
// Conducts and reports an Axe test.
|
|
12
|
-
exports.reporter = async (page,
|
|
25
|
+
exports.reporter = async (page, detailLevel, rules = []) => {
|
|
13
26
|
// Initialize the report.
|
|
14
27
|
const data = {};
|
|
15
28
|
// Inject axe-core into the page.
|
|
@@ -22,81 +35,65 @@ exports.reporter = async (page, withItems, rules = []) => {
|
|
|
22
35
|
// If the injection succeeded:
|
|
23
36
|
if (! data.prevented) {
|
|
24
37
|
// Get the data on the elements violating the specified axe-core rules.
|
|
25
|
-
const axeOptions = {
|
|
38
|
+
const axeOptions = {
|
|
39
|
+
resultTypes: ['violations', 'incomplete']
|
|
40
|
+
};
|
|
26
41
|
if (rules.length) {
|
|
27
42
|
axeOptions.runOnly = rules;
|
|
28
43
|
}
|
|
29
|
-
|
|
44
|
+
else {
|
|
45
|
+
axeOptions.runOnly = ['experimental', 'best-practice', 'wcag2a', 'wcag2aa', 'wcag2aaa', 'wcag21a', 'wcag21aa', 'wcag21aaa'];
|
|
46
|
+
}
|
|
47
|
+
const axeReport = await getAxeResults(page, null, axeOptions)
|
|
30
48
|
.catch(error => {
|
|
31
49
|
console.log(`ERROR: Axe failed (${error.message}'`);
|
|
32
50
|
return '';
|
|
33
51
|
});
|
|
34
52
|
// If the test succeeded:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
data.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
const {inapplicable, passes, incomplete, violations} = axeReport;
|
|
54
|
+
if (violations) {
|
|
55
|
+
// Initialize the result.
|
|
56
|
+
data.totals = {
|
|
57
|
+
rulesNA: 0,
|
|
58
|
+
rulesPassed: 0,
|
|
59
|
+
rulesWarned: 0,
|
|
60
|
+
rulesViolated: 0,
|
|
61
|
+
warnings: {
|
|
62
|
+
minor: 0,
|
|
63
|
+
moderate: 0,
|
|
64
|
+
serious: 0,
|
|
65
|
+
critical: 0
|
|
66
|
+
},
|
|
67
|
+
violations: {
|
|
68
|
+
minor: 0,
|
|
69
|
+
moderate: 0,
|
|
70
|
+
serious: 0,
|
|
71
|
+
critical: 0
|
|
72
|
+
}
|
|
43
73
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const compactViolator = elObj => {
|
|
60
|
-
const out = {
|
|
61
|
-
selector: elObj.target[0],
|
|
62
|
-
impact: elObj.impact
|
|
63
|
-
};
|
|
64
|
-
if (elObj.any && elObj.any.length) {
|
|
65
|
-
out['must pass any of'] = elObj.any.map(checkObj => compactCheck(checkObj));
|
|
66
|
-
}
|
|
67
|
-
if (elObj.none && elObj.none.length) {
|
|
68
|
-
out['must pass all of'] = elObj.none.map(checkObj => compactCheck(checkObj));
|
|
69
|
-
}
|
|
70
|
-
return out;
|
|
71
|
-
};
|
|
72
|
-
// Compacts a violated rule.
|
|
73
|
-
const compactRule = rule => {
|
|
74
|
-
const out = {
|
|
75
|
-
rule: rule.id,
|
|
76
|
-
description: rule.description,
|
|
77
|
-
impact: rule.impact,
|
|
78
|
-
elements: {}
|
|
79
|
-
};
|
|
80
|
-
if (rule.nodes && rule.nodes.length) {
|
|
81
|
-
out.elements = rule.nodes.map(el => compactViolator(el));
|
|
82
|
-
}
|
|
83
|
-
return out;
|
|
84
|
-
};
|
|
85
|
-
// FUNCTION DEFINITIONS END
|
|
86
|
-
// For each rule violated:
|
|
87
|
-
axeReport.forEach(rule => {
|
|
88
|
-
// For each element violating the rule:
|
|
89
|
-
rule.nodes.forEach(element => {
|
|
90
|
-
// Increment the element count of the impact of its violation.
|
|
91
|
-
data.violations[element.impact]++;
|
|
92
|
-
});
|
|
93
|
-
// If details are required:
|
|
94
|
-
if (withItems) {
|
|
95
|
-
// Add it to the report.
|
|
96
|
-
data.items.push(compactRule(rule));
|
|
97
|
-
}
|
|
74
|
+
data.details = axeReport;
|
|
75
|
+
// Populate the totals.
|
|
76
|
+
const {totals} = data;
|
|
77
|
+
totals.rulesNA = inapplicable.length;
|
|
78
|
+
totals.rulesPassed = passes.length;
|
|
79
|
+
incomplete.forEach(rule => {
|
|
80
|
+
totals.rulesWarned++;
|
|
81
|
+
rule.nodes.forEach(node => {
|
|
82
|
+
totals.warnings[node.impact]++;
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
violations.forEach(rule => {
|
|
86
|
+
totals.rulesViolated++;
|
|
87
|
+
rule.nodes.forEach(node => {
|
|
88
|
+
totals.violations[node.impact]++;
|
|
98
89
|
});
|
|
99
|
-
}
|
|
90
|
+
});
|
|
91
|
+
// Delete irrelevant properties from the report details.
|
|
92
|
+
const irrelevants = ['inapplicable', 'passes', 'incomplete', 'violations']
|
|
93
|
+
.slice(0, 4 - detailLevel);
|
|
94
|
+
irrelevants.forEach(irrelevant => {
|
|
95
|
+
delete axeReport[irrelevant];
|
|
96
|
+
});
|
|
100
97
|
}
|
|
101
98
|
// Otherwise, i.e. if the test failed:
|
|
102
99
|
else {
|
package/tests/motion.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
between screen shots (interval), and how many screen shots to make (count). The test compares the
|
|
10
10
|
screen shots and reports 9 statistics:
|
|
11
11
|
0. bytes: an array of the sizes of the screen shots, in bytes
|
|
12
|
-
1. localRatios: an array of the ratios of bytes of the larger to the smaller of adjacent pairs
|
|
12
|
+
1. localRatios: an array of the ratios of bytes of the larger to the smaller of adjacent pairs
|
|
13
|
+
of screen shots
|
|
13
14
|
2. meanLocalRatio: the mean of the ratios in the localRatios array
|
|
14
15
|
3. maxLocalRatio: the greatest of the ratios in the localRatios array
|
|
15
16
|
4. globalRatio: the ratio of bytes of the largest to the smallest screen shot
|
|
@@ -17,6 +18,10 @@
|
|
|
17
18
|
6. meanPixelChange: the mean of the counts in the pixelChanges array
|
|
18
19
|
7. maxPixelChange: the greatest of the counts in the pixelChanges array
|
|
19
20
|
8. changeFrequency: what fraction of the adjacent pairs of screen shots has pixel differences
|
|
21
|
+
|
|
22
|
+
WARNING: This test uses the Playwright page.screenshot method, which produces incorrect results
|
|
23
|
+
when the browser type is chromium and is not implemented for the firefox browser type. The only
|
|
24
|
+
browser type usable with this test is webkit.
|
|
20
25
|
*/
|
|
21
26
|
const pixelmatch = require('pixelmatch');
|
|
22
27
|
const {PNG} = require('pngjs');
|