testaro 8.4.2 → 8.4.4

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.
Files changed (3) hide show
  1. package/commands.js +2 -1
  2. package/package.json +1 -1
  3. package/run.js +7 -5
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "8.4.2",
3
+ "version": "8.4.4",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -263,8 +263,8 @@ const isValidReport = report => {
263
263
  [commands[1].which, 'second command has which property'],
264
264
  [isURL(commands[1].which), 'second command which property has URL value'],
265
265
  [commands.every(command => isValidCommand(command)), 'every command is valid'],
266
- [typeof sources.script === 'string', 'sources has script property with string value'],
267
- [sources.host, 'sources has host property']
266
+ [sources && typeof sources.script === 'string', 'sources has script property with string value'],
267
+ [sources && sources.host, 'sources has host property']
268
268
  ];
269
269
  const invalidityIndex = criteria.findIndex(criterion => ! criterion[0]);
270
270
  if (invalidityIndex > -1) {
@@ -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
- browserContext = await browser.newContext();
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
  }