testaro 10.1.0 → 10.2.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/actSpecs.js +6 -0
- package/package.json +1 -1
- package/run.js +5 -0
- package/tests/alfa.js +5 -0
- package/tests/continuum.js +15 -4
package/actSpecs.js
CHANGED
|
@@ -175,6 +175,12 @@ exports.actSpecs = {
|
|
|
175
175
|
rules: [true, 'array', 'areStrings', 'rule names, or empty if all']
|
|
176
176
|
}
|
|
177
177
|
],
|
|
178
|
+
continuum: [
|
|
179
|
+
'Perform a continuum test',
|
|
180
|
+
{
|
|
181
|
+
rules: [false, 'array', 'areNumbers', 'rule numbers (e.g., 25), if not all']
|
|
182
|
+
}
|
|
183
|
+
],
|
|
178
184
|
elements: [
|
|
179
185
|
'Perform an elements test',
|
|
180
186
|
{
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -119,6 +119,8 @@ const isState = string => ['loaded', 'idle'].includes(string);
|
|
|
119
119
|
const isURL = string => /^(?:https?|file):\/\/[^\s]+$/.test(string);
|
|
120
120
|
// Validates a focusable tag name.
|
|
121
121
|
const isFocusable = string => ['a', 'button', 'input', 'select'].includes(string);
|
|
122
|
+
// Returns whether all elements of an array are numbers.
|
|
123
|
+
const areNumbers = array => array.every(element => typeof element === 'number');
|
|
122
124
|
// Returns whether all elements of an array are strings.
|
|
123
125
|
const areStrings = array => array.every(element => typeof element === 'string');
|
|
124
126
|
// Returns whether a variable has a specified type.
|
|
@@ -160,6 +162,9 @@ const hasSubtype = (variable, subtype) => {
|
|
|
160
162
|
else if (subtype === 'isWaitable') {
|
|
161
163
|
return waitables.includes(variable);
|
|
162
164
|
}
|
|
165
|
+
else if (subtype === 'areNumbers') {
|
|
166
|
+
return areNumbers(variable);
|
|
167
|
+
}
|
|
163
168
|
else if (subtype === 'areStrings') {
|
|
164
169
|
return areStrings(variable);
|
|
165
170
|
}
|
package/tests/alfa.js
CHANGED
|
@@ -49,6 +49,7 @@ exports.reporter = async (page, rules) => {
|
|
|
49
49
|
});
|
|
50
50
|
await rulePage.close();
|
|
51
51
|
}
|
|
52
|
+
// Initialize the result.
|
|
52
53
|
const data = {
|
|
53
54
|
totals: {
|
|
54
55
|
failures: 0,
|
|
@@ -57,15 +58,19 @@ exports.reporter = async (page, rules) => {
|
|
|
57
58
|
items: []
|
|
58
59
|
};
|
|
59
60
|
await Scraper.with(async scraper => {
|
|
61
|
+
// Get the page content.
|
|
60
62
|
for (const input of await scraper.scrape(page.url())) {
|
|
63
|
+
// Test it with the specified rules.
|
|
61
64
|
const audit = Audit.of(input, alfaRules);
|
|
62
65
|
const outcomes = Array.from(await audit.evaluate());
|
|
66
|
+
// For each failure or warning:
|
|
63
67
|
outcomes.forEach((outcome, index) => {
|
|
64
68
|
const {target} = outcome;
|
|
65
69
|
if (target && ! target._members) {
|
|
66
70
|
const outcomeJ = outcome.toJSON();
|
|
67
71
|
const verdict = outcomeJ.outcome;
|
|
68
72
|
if (verdict !== 'passed') {
|
|
73
|
+
// Add to the result.
|
|
69
74
|
const {rule} = outcomeJ;
|
|
70
75
|
const {tags, uri, requirements} = rule;
|
|
71
76
|
const ruleID = uri.replace(/^.+-/, '');
|
package/tests/continuum.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// FUNCTIONS
|
|
8
8
|
// Runs Continuum on the page.
|
|
9
|
-
exports.reporter = async page => {
|
|
9
|
+
exports.reporter = async (page, rules) => {
|
|
10
10
|
let result = {};
|
|
11
11
|
// Inject the continuum scripts into the page, exposing the continuum object.
|
|
12
12
|
for (const fileName of ['continuum.conf', 'AccessEngine.community', 'Continuum.community']) {
|
|
@@ -23,9 +23,20 @@ exports.reporter = async page => {
|
|
|
23
23
|
}
|
|
24
24
|
if (! result.prevented) {
|
|
25
25
|
// Run the Continuum ruleset and get the result, failing if none within 20 seconds.
|
|
26
|
-
result = await page.evaluate(async
|
|
26
|
+
result = await page.evaluate(async rules => {
|
|
27
27
|
continuum.setUp(null, null, window);
|
|
28
|
-
|
|
28
|
+
// If a set of rules to be employed was specified:
|
|
29
|
+
let bigResultPromise;
|
|
30
|
+
if (rules && Array.isArray(rules) && rules.length && rules.every(rule => typeof rule === 'number')) {
|
|
31
|
+
// Run the tests for them.
|
|
32
|
+
bigResultPromise = continuum.runTests(rules);
|
|
33
|
+
}
|
|
34
|
+
// Otherwise, i.e. if no rules were specified:
|
|
35
|
+
else {
|
|
36
|
+
// Run all the tests.
|
|
37
|
+
bigResultPromise = continuum.runAllTests();
|
|
38
|
+
}
|
|
39
|
+
// Allow 20 seconds for the result compilation.
|
|
29
40
|
const deadlinePromise = new Promise(resolve => {
|
|
30
41
|
setTimeout(() => {
|
|
31
42
|
resolve('timeout');
|
|
@@ -54,7 +65,7 @@ exports.reporter = async page => {
|
|
|
54
65
|
error: 'ERROR: Invalid result'
|
|
55
66
|
};
|
|
56
67
|
}
|
|
57
|
-
});
|
|
68
|
+
}, rules);
|
|
58
69
|
}
|
|
59
70
|
return {result};
|
|
60
71
|
};
|