testaro 8.4.1 → 8.4.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/commands.js +2 -1
- package/package.json +1 -1
- package/run.js +5 -3
- package/tests/attVal.js +5 -2
package/commands.js
CHANGED
|
@@ -28,7 +28,8 @@ exports.commands = {
|
|
|
28
28
|
'Launch a Playwright browser',
|
|
29
29
|
{
|
|
30
30
|
which: [true, 'string', 'isBrowserType', '“chromium”, “firefox”, or “webkit”'],
|
|
31
|
-
what: [false, 'string', 'hasLength', 'comment']
|
|
31
|
+
what: [false, 'string', 'hasLength', 'comment'],
|
|
32
|
+
lowMotion: [false, 'boolean', '', 'set reduced-motion option if true']
|
|
32
33
|
}
|
|
33
34
|
],
|
|
34
35
|
link: [
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -294,7 +294,7 @@ const browserClose = async () => {
|
|
|
294
294
|
// Returns the first line of an error message.
|
|
295
295
|
const errorStart = error => error.message.replace(/\n.+/s, '');
|
|
296
296
|
// Launches a browser.
|
|
297
|
-
const launch = async (report, typeName) => {
|
|
297
|
+
const launch = async (report, typeName, lowMotion = false) => {
|
|
298
298
|
const browserType = require('playwright')[typeName];
|
|
299
299
|
// If the specified browser type exists:
|
|
300
300
|
if (browserType) {
|
|
@@ -316,7 +316,9 @@ const launch = async (report, typeName) => {
|
|
|
316
316
|
});
|
|
317
317
|
// If the launch succeeded:
|
|
318
318
|
if (healthy) {
|
|
319
|
-
|
|
319
|
+
// Open a context (i.e. browser tab), with reduced motion if specified.
|
|
320
|
+
const options = {reduceMotion: lowMotion ? 'reduce' : 'no-preference'};
|
|
321
|
+
browserContext = await browser.newContext(options);
|
|
320
322
|
// When a page (i.e. browser tab) is added to the browser context (i.e. browser window):
|
|
321
323
|
browserContext.on('page', async page => {
|
|
322
324
|
// Make the page current.
|
|
@@ -659,7 +661,7 @@ const doActs = async (report, actIndex, page) => {
|
|
|
659
661
|
// Otherwise, if the command is a launch:
|
|
660
662
|
else if (act.type === 'launch') {
|
|
661
663
|
// Launch the specified browser, creating a browser context and a page in it.
|
|
662
|
-
await launch(report, act.which);
|
|
664
|
+
await launch(report, act.which, act.lowMotion ? 'reduce' : 'no-preference');
|
|
663
665
|
// Identify its only page as current.
|
|
664
666
|
page = browserContext.pages()[0];
|
|
665
667
|
}
|
package/tests/attVal.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.reporter = async (page, attributeName, areLicit, values, withItems) => {
|
|
|
7
7
|
const badAttributeData = await page.evaluate(
|
|
8
8
|
args => {
|
|
9
9
|
const attributeName = args[0];
|
|
10
|
+
// Whether the values are the licit or the illicit ones.
|
|
10
11
|
const areLicit = args[1];
|
|
11
12
|
const values = args[2];
|
|
12
13
|
// Returns the text of an element.
|
|
@@ -15,15 +16,17 @@ exports.reporter = async (page, attributeName, areLicit, values, withItems) => {
|
|
|
15
16
|
text = text.trim() || element.innerHTML;
|
|
16
17
|
return text.replace(/\s+/sg, ' ').replace(/<>&/g, '').slice(0, limit);
|
|
17
18
|
};
|
|
19
|
+
// Get the elements (including the html element) with the attribute.
|
|
18
20
|
const attributeElements = Array.from(document.querySelectorAll(`[${attributeName}]`));
|
|
21
|
+
// Get those in which the attribute has an illicit value.
|
|
19
22
|
const badElements = attributeElements
|
|
20
23
|
.filter(el => {
|
|
21
24
|
const value = el.getAttribute(attributeName);
|
|
22
25
|
if (areLicit) {
|
|
23
|
-
return values.includes(value);
|
|
26
|
+
return ! values.includes(value);
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
26
|
-
return
|
|
29
|
+
return values.includes(value);
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
const report = badElements.map(el => ({
|