testaro 5.5.10 → 5.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/run.js +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.5.10",
3
+ "version": "5.6.0",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -500,6 +500,7 @@ const goto = async (page, url, timeout, waitUntil, isStrict) => {
500
500
  if (url.startsWith('file://.')) {
501
501
  url = url.replace('file://', `file://${__dirname}/`);
502
502
  }
503
+ // Visit the URL.
503
504
  const response = await page.goto(url, {
504
505
  timeout,
505
506
  waitUntil
@@ -509,25 +510,37 @@ const goto = async (page, url, timeout, waitUntil, isStrict) => {
509
510
  visitTimeoutCount++;
510
511
  return 'error';
511
512
  });
513
+ // If the visit succeeded:
512
514
  if (typeof response !== 'string') {
513
515
  const httpStatus = response.status();
516
+ // If the response status was normal:
514
517
  if ([200, 304].includes(httpStatus) || url.startsWith('file:')) {
518
+ // If the browser was redirected in violation of a strictness requirement.
515
519
  const actualURL = page.url();
516
520
  if (isStrict && deSlash(actualURL) !== deSlash(url)) {
521
+ // Return an error.
517
522
  console.log(`ERROR: Visit to ${url} redirected to ${actualURL}`);
518
523
  return 'redirection';
519
524
  }
525
+ // Otherwise, i.e. if no prohibited redirection occurred:
520
526
  else {
527
+ // Press the Escape key to dismiss any modal dialog.
528
+ await page.keyboard.press('Escape');
529
+ // Return the response.
521
530
  return response;
522
531
  }
523
532
  }
533
+ // Otherwise, i.e. if the response status was abnormal:
524
534
  else {
535
+ // Return an error.
525
536
  console.log(`ERROR: Visit to ${url} got status ${httpStatus}`);
526
537
  visitRejectionCount++;
527
538
  return 'error';
528
539
  }
529
540
  }
541
+ // Otherwise, i.e. if the visit failed:
530
542
  else {
543
+ // Return an error.
531
544
  return 'error';
532
545
  }
533
546
  };