testaro 32.2.1 → 32.2.3
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/package.json +1 -1
- package/run.js +2 -0
- package/testaro/headingAmb.js +17 -15
- package/tests/qualWeb.js +8 -2
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -422,6 +422,8 @@ const launch = async (report, typeName, url, debug, waits, isLowMotion = false)
|
|
|
422
422
|
// Open a context (i.e. browser tab), with reduced motion if specified.
|
|
423
423
|
const options = {reduceMotion: isLowMotion ? 'reduce' : 'no-preference'};
|
|
424
424
|
const browserContext = await browser.newContext(options);
|
|
425
|
+
// Prevent default timeouts, including those arising from a Playwright bug.
|
|
426
|
+
browserContext.setDefaultTimeout(0);
|
|
425
427
|
// When a page (i.e. browser tab) is added to the browser context (i.e. browser window):
|
|
426
428
|
browserContext.on('page', async page => {
|
|
427
429
|
// If it emits a message:
|
package/testaro/headingAmb.js
CHANGED
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
/*
|
|
24
24
|
headingAmb
|
|
25
25
|
Related to ASLint rule headings-sibling-unique.
|
|
26
|
-
This test reports
|
|
27
|
-
contents.
|
|
26
|
+
This test reports adjacent headings with the same levels and text contents.
|
|
28
27
|
*/
|
|
29
28
|
|
|
30
29
|
// ########## IMPORTS
|
|
@@ -49,21 +48,24 @@ exports.reporter = async (page, withItems) => {
|
|
|
49
48
|
const badIndexes = [];
|
|
50
49
|
// For each heading:
|
|
51
50
|
headings.forEach((heading, index) => {
|
|
52
|
-
//
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
// Get its level.
|
|
52
|
+
const level = heading.level;
|
|
53
|
+
// If there are prior non-inferior headings and the last one has the same-level and text:
|
|
54
|
+
// Get the prior headings.
|
|
55
|
+
const priorHeadings = headings.slice(0, index);
|
|
56
|
+
// Get the non-inferior ones among them.
|
|
57
|
+
const nonInferiors = priorHeadings.filter(priorHeading => priorHeading.level <= level);
|
|
58
|
+
// If there are any:
|
|
59
|
+
const nonInferiorCount = nonInferiors.length;
|
|
60
|
+
if (nonInferiorCount) {
|
|
61
|
+
// Get the last of them.
|
|
62
|
+
const prior = nonInferiors[nonInferiorCount - 1];
|
|
63
|
+
// If they have the same level and text:
|
|
55
64
|
if (['tagName', 'textContent'].every(property => prior[property] === heading[property])) {
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
headings
|
|
59
|
-
.slice(priorIndex + 1, index)
|
|
60
|
-
.every(betweenHeading => betweenHeading.tagName[1] >= heading.tagName[1])
|
|
61
|
-
) {
|
|
62
|
-
// Add the index of the later heading to the index of violating headings.
|
|
63
|
-
badIndexes.push(headings.indexOf(heading));
|
|
64
|
-
}
|
|
65
|
+
// Add the index of the later heading to the index of violating headings.
|
|
66
|
+
badIndexes.push(index);
|
|
65
67
|
}
|
|
66
|
-
}
|
|
68
|
+
}
|
|
67
69
|
});
|
|
68
70
|
return badIndexes;
|
|
69
71
|
});
|
package/tests/qualWeb.js
CHANGED
|
@@ -42,6 +42,7 @@ const clusterOptions = {
|
|
|
42
42
|
exports.reporter = async (page, options) => {
|
|
43
43
|
const {withNewContent, rules} = options;
|
|
44
44
|
const data = {};
|
|
45
|
+
let result = {};
|
|
45
46
|
// Start the QualWeb core engine.
|
|
46
47
|
await qualWeb.start(clusterOptions);
|
|
47
48
|
// Specify the invariant test options.
|
|
@@ -126,7 +127,7 @@ exports.reporter = async (page, options) => {
|
|
|
126
127
|
// Get the report.
|
|
127
128
|
let actReports = await qualWeb.evaluate(qualWebOptions);
|
|
128
129
|
// Remove the copy of the DOM from it.
|
|
129
|
-
|
|
130
|
+
result = actReports[withNewContent ? qualWebOptions.url : 'customHtml'];
|
|
130
131
|
if (result && result.system && result.system.page && result.system.page.dom) {
|
|
131
132
|
delete result.system.page.dom;
|
|
132
133
|
// For each test section of the act report:
|
|
@@ -202,8 +203,13 @@ exports.reporter = async (page, options) => {
|
|
|
202
203
|
};
|
|
203
204
|
}
|
|
204
205
|
catch(error) {
|
|
206
|
+
const message = error.message.slice(0, 200);
|
|
205
207
|
data.prevented = true;
|
|
206
|
-
data.error =
|
|
208
|
+
data.error = message;
|
|
209
|
+
result = {
|
|
210
|
+
prevented: true,
|
|
211
|
+
error: message
|
|
212
|
+
};
|
|
207
213
|
};
|
|
208
214
|
return {
|
|
209
215
|
data,
|