testaro 60.12.0 → 60.13.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.
package/tests/testaro.js CHANGED
@@ -409,7 +409,7 @@ const allRules = [
409
409
  id: 'hover',
410
410
  what: 'hover-caused content changes',
411
411
  launchRole: 'waster',
412
- timeOut: 10,
412
+ timeOut: 300,
413
413
  defaultOn: true
414
414
  },
415
415
  {
@@ -582,8 +582,9 @@ exports.reporter = async (page, report, actIndex) => {
582
582
  ruleArgs.push(... args[ruleID]);
583
583
  }
584
584
  result[ruleID] ??= {};
585
+ const ruleResult = result[ruleID];
585
586
  const {what} = rule;
586
- result[ruleID].what = what || '';
587
+ ruleResult.what = what || '';
587
588
  const startTime = Date.now();
588
589
  let timeout;
589
590
  let testRetries = 2;
@@ -600,8 +601,8 @@ exports.reporter = async (page, report, actIndex) => {
600
601
  testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
601
602
  data.rulePreventions.push(ruleID);
602
603
  data.rulePreventionMessages[ruleID] = 'Timeout';
603
- result[ruleID].totals = [0, 0, 0, 0];
604
- result[ruleID].standardInstances = [];
604
+ ruleResult.totals = [0, 0, 0, 0];
605
+ ruleResult.standardInstances = [];
605
606
  console.log(`ERROR: Test of testaro rule ${ruleID} timed out`);
606
607
  resolve({timedOut: true});
607
608
  }, timeLimit);
@@ -618,26 +619,32 @@ exports.reporter = async (page, report, actIndex) => {
618
619
  const endTime = Date.now();
619
620
  testTimes.push([ruleID, Math.round((endTime - startTime) / 1000)]);
620
621
  Object.keys(ruleOrTimeoutReport).forEach(key => {
621
- result[ruleID][key] = ruleOrTimeoutReport[key];
622
+ ruleResult[key] = ruleOrTimeoutReport[key];
622
623
  });
624
+ // If the test was prevented:
625
+ if (ruleResult.data?.prevented && ruleResult.data.error) {
626
+ // Add this to the result.
627
+ data.rulePreventions.push(ruleID);
628
+ data.rulePreventionMessages[ruleID] = ruleResult.data.error;
629
+ }
623
630
  // If the result includes totals:
624
- if (result[ruleID].totals) {
631
+ if (ruleResult.totals) {
625
632
  // Round them.
626
- result[ruleID].totals = result[ruleID].totals.map(total => Math.round(total));
633
+ ruleResult.totals = ruleResult.totals.map(total => Math.round(total));
627
634
  }
628
635
  // Prevent a retry of the test.
629
636
  testSuccess = true;
630
637
  // If testing is to stop after a failure and the page failed the test:
631
- if (
632
- stopOnFail
633
- && ruleOrTimeoutReport.totals
634
- && ruleOrTimeoutReport.totals.some(total => total)) {
638
+ if (stopOnFail && ruleResult.totals && ruleResult.totals.some(total => total)) {
635
639
  // Stop testing.
636
640
  break;
637
641
  }
638
642
  }
639
643
  // Otherwise, i.e. if the test timed out:
640
644
  else {
645
+ // Report this.
646
+ data.rulePreventions.push(ruleID);
647
+ data.rulePreventionMessages[ruleID] = 'Timeout';
641
648
  // Stop retrying the test.
642
649
  break;
643
650
  }