testaro 5.11.1 → 5.11.2

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 +39 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.11.1",
3
+ "version": "5.11.2",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -12,7 +12,7 @@ const {commands} = require('./commands');
12
12
 
13
13
  // ########## CONSTANTS
14
14
 
15
- // Set DEBUG environment variable to 'true,' to add debugging features.
15
+ // Set DEBUG environment variable to 'true' to add debugging features.
16
16
  const debug = process.env.DEBUG === 'true';
17
17
  // Set WAITS environment variable to a positive number to insert delays (in ms).
18
18
  const waits = Number.parseInt(process.env.WAITS) || 0;
@@ -492,11 +492,11 @@ const visit = async (act, page, isStrict) => {
492
492
  // Identify the URL.
493
493
  const resolved = act.which.replace('__dirname', __dirname);
494
494
  requestedURL = resolved;
495
- // Visit it and wait 15 seconds or until the network is idle.
495
+ // Visit it and wait until the network is idle.
496
496
  let response = await goto(page, requestedURL, 15000, 'networkidle', isStrict);
497
497
  // If the visit fails:
498
498
  if (response === 'error') {
499
- // Try again, but waiting 10 seconds or until the DOM is loaded.
499
+ // Try again until the DOM is loaded.
500
500
  response = await goto(page, requestedURL, 10000, 'domcontentloaded', isStrict);
501
501
  // If the visit fails:
502
502
  if (response === 'error') {
@@ -507,15 +507,15 @@ const visit = async (act, page, isStrict) => {
507
507
  await launch(newBrowserName);
508
508
  // Identify its only page as current.
509
509
  page = browserContext.pages()[0];
510
- // Try again, waiting 10 seconds or until the network is idle.
510
+ // Try again until the network is idle.
511
511
  response = await goto(page, requestedURL, 10000, 'networkidle', isStrict);
512
512
  // If the visit fails:
513
513
  if (response === 'error') {
514
- // Try again, but waiting 5 seconds or until the DOM is loaded.
514
+ // Try again until the DOM is loaded.
515
515
  response = await goto(page, requestedURL, 5000, 'domcontentloaded', isStrict);
516
516
  // If the visit fails:
517
517
  if (response === 'error') {
518
- // Try again, waiting 5 seconds or until a load.
518
+ // Try again or until a load.
519
519
  response = await goto(page, requestedURL, 5000, 'load', isStrict);
520
520
  // If the visit fails:
521
521
  if (response === 'error') {
@@ -626,8 +626,8 @@ const doActs = async (report, actIndex, page) => {
626
626
  const logSuffix = condition.length === 3 ? ` ${condition[1]} ${condition[2]}` : '';
627
627
  console.log(`>> ${condition[0]}${logSuffix}`);
628
628
  // Identify the act to be checked.
629
- const ifActIndex = report.acts.map(act => act.type !== 'next').lastIndexOf(true,);
630
- // Determine whether its jump condition is true,.
629
+ const ifActIndex = report.acts.map(act => act.type !== 'next').lastIndexOf(true);
630
+ // Determine whether its jump condition is true.
631
631
  const truth = isTrue(report.acts[ifActIndex].result, condition);
632
632
  // Add the result to the act.
633
633
  act.result = {
@@ -637,7 +637,7 @@ const doActs = async (report, actIndex, page) => {
637
637
  value: truth[0],
638
638
  jumpRequired: truth[1]
639
639
  };
640
- // If the condition is true,:
640
+ // If the condition is true:
641
641
  if (truth[1]) {
642
642
  // If the performance of commands is to stop:
643
643
  if (act.jump === 0) {
@@ -677,7 +677,7 @@ const doActs = async (report, actIndex, page) => {
677
677
  const result = act.result = {};
678
678
  // If the text is to be the URL:
679
679
  if (what === 'url') {
680
- // Wait for it up to 15 seconds and quit on failure.
680
+ // Wait for it and quit on failure.
681
681
  try {
682
682
  await page.waitForURL(which, {timeout: 15000});
683
683
  result.found = true;
@@ -690,7 +690,7 @@ const doActs = async (report, actIndex, page) => {
690
690
  }
691
691
  // Otherwise, if the text is to be a substring of the page title:
692
692
  else if (what === 'title') {
693
- // Wait for it up to 5 seconds and quit on failure.
693
+ // Wait for it and quit on failure.
694
694
  try {
695
695
  await page.waitForFunction(
696
696
  text => document
@@ -712,7 +712,7 @@ const doActs = async (report, actIndex, page) => {
712
712
  }
713
713
  // Otherwise, if the text is to be a substring of the text of the page body:
714
714
  else if (what === 'body') {
715
- // Wait for it up to 10 seconds and quit on failure.
715
+ // Wait for it and quit on failure.
716
716
  try {
717
717
  await page.waitForFunction(
718
718
  text => document
@@ -734,10 +734,10 @@ const doActs = async (report, actIndex, page) => {
734
734
  }
735
735
  // Otherwise, if the act is a wait for a state:
736
736
  else if (act.type === 'state') {
737
- // Wait for it up to 5 or 10 seconrds, and quit on failure.
737
+ // Wait for it and quit on failure.
738
738
  const stateIndex = ['loaded', 'idle'].indexOf(act.which);
739
739
  await page.waitForLoadState(
740
- ['domcontentloaded', 'networkidle'][stateIndex], {timeout: [10000, 5000][stateIndex]}
740
+ ['domcontentloaded', 'networkidle'][stateIndex], {timeout: [10000, 15000][stateIndex]}
741
741
  )
742
742
  .catch(error => {
743
743
  console.log(`ERROR waiting for page to be ${act.which} (${error.message})`);
@@ -758,8 +758,8 @@ const doActs = async (report, actIndex, page) => {
758
758
  else if (act.type === 'page') {
759
759
  // Wait for a page to be created and identify it as current.
760
760
  page = await browserContext.waitForEvent('page');
761
- // Wait up to 20 seconds until it is idle.
762
- await page.waitForLoadState('networkidle', {timeout: 20000});
761
+ // Wait until it is idle.
762
+ await page.waitForLoadState('networkidle', {timeout: 15000});
763
763
  // Add the resulting URL to the act.
764
764
  const result = {
765
765
  url: page.url()
@@ -778,7 +778,7 @@ const doActs = async (report, actIndex, page) => {
778
778
  // Make all elements in the page visible.
779
779
  await require('./procs/allVis').allVis(page);
780
780
  act.result = {
781
- success: true,
781
+ success: true
782
782
  };
783
783
  }
784
784
  // Otherwise, if the act is a tenon request:
@@ -944,7 +944,7 @@ const doActs = async (report, actIndex, page) => {
944
944
  // Otherwise, if the act is a move:
945
945
  else if (moves[act.type]) {
946
946
  const selector = typeof moves[act.type] === 'string' ? moves[act.type] : act.what;
947
- // Try for up to 10 seconds to identify the element to perform the move on.
947
+ // Try to identify the element to perform the move on.
948
948
  act.result = {found: false};
949
949
  let selection = {};
950
950
  let tries = 0;
@@ -1086,7 +1086,7 @@ const doActs = async (report, actIndex, page) => {
1086
1086
  selection.click({timeout: 5000})
1087
1087
  ]);
1088
1088
  // Wait for the new page to load.
1089
- await newPage.waitForLoadState('domcontentloaded', {timeout: 6000});
1089
+ await newPage.waitForLoadState('domcontentloaded', {timeout: 10000});
1090
1090
  // Make the new page the current page.
1091
1091
  page = newPage;
1092
1092
  act.result.success = true;
@@ -1101,34 +1101,32 @@ const doActs = async (report, actIndex, page) => {
1101
1101
  );
1102
1102
  act.result.success = false;
1103
1103
  act.result.error = 'unclickable';
1104
- act.result.message = 'ERROR: click and new-page navigation timed out';
1104
+ act.result.message = 'ERROR: click, navigation, or load timed out';
1105
1105
  actIndex = -2;
1106
1106
  }
1107
1107
  }
1108
1108
  // Otherwise, i.e. if the destination is in the current page:
1109
1109
  else {
1110
1110
  // Click the link and wait for the resulting navigation.
1111
- await selection.click({timeout: 5000})
1112
- // If the click and navigation time out:
1113
- .catch(async error => {
1114
- // Try to force-click it and wait for the navigation.
1115
- const errorSummary = error.message.replace(/\n.+/s, '');
1116
- console.log(`ERROR: Link to ${href} not clickable (${errorSummary})`);
1117
- await selection.click({
1118
- force: true,
1119
- timeout: 3000
1120
- })
1121
- // If it cannot be force-clicked:
1122
- .catch(error => {
1123
- // Quit and report the failure.
1124
- actIndex = -2;
1125
- const errorSummary = error.message.replace(/\n.+/s, '');
1126
- console.log(`ERROR: Link to ${href} not force-clickable (${errorSummary})`);
1127
- act.result.success = false;
1128
- act.result.error = 'unclickable';
1129
- act.result.message = 'ERROR: Normal and forced click attempts timed out';
1130
- });
1131
- });
1111
+ try {
1112
+ await selection.click({timeout: 5000});
1113
+ // Wait for the new content to load.
1114
+ await page.waitForLoadState('domcontentloaded', {timeout: 4000});
1115
+ act.result.success = true;
1116
+ act.result.move = 'clicked';
1117
+ act.result.newURL = page.url();
1118
+ }
1119
+ // If the click or load failed:
1120
+ catch(error) {
1121
+ // Quit and report the failure.
1122
+ console.log(
1123
+ `ERROR clicking link (${error.message.replace(/\n.+/s, '')})`
1124
+ );
1125
+ act.result.success = false;
1126
+ act.result.error = 'unclickable';
1127
+ act.result.message = 'ERROR: click or load timed out';
1128
+ actIndex = -2;
1129
+ }
1132
1130
  // If the link click succeeded:
1133
1131
  if (! act.result.error) {
1134
1132
  act.result.success = true;