testaro 12.5.3 → 12.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "12.5.3",
3
+ "version": "12.7.1",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "accessibility-checker": "*",
36
36
  "axe-playwright": "*",
37
37
  "dotenv": "*",
38
- "node-fetch": "*",
38
+ "node-fetch": "<3.0.0",
39
39
  "pixelmatch": "*",
40
40
  "playwright": "*"
41
41
  },
package/run.js CHANGED
@@ -341,14 +341,13 @@ const launch = async (report, typeName, lowMotion = false) => {
341
341
  browserContext.on('page', async page => {
342
342
  // Make the page current.
343
343
  currentPage = page;
344
- // Make its console messages get reported in the Playwright console.
344
+ // If it emits a message:
345
345
  page.on('console', msg => {
346
346
  const msgText = msg.text();
347
347
  let indentedMsg = '';
348
+ // If debugging is on:
348
349
  if (debug) {
349
- indentedMsg = ` | ${msg.text()}`;
350
- }
351
- else {
350
+ // Log a summary of the message on the console.
352
351
  const parts = [msgText.slice(0, 75)];
353
352
  if (msgText.length > 75) {
354
353
  parts.push(msgText.slice(75, 150));
@@ -364,8 +363,9 @@ const launch = async (report, typeName, lowMotion = false) => {
364
363
  }
365
364
  }
366
365
  indentedMsg = parts.map(part => ` | ${part}`).join('\n');
366
+ console.log(`\n${indentedMsg}`);
367
367
  }
368
- console.log(`\n${indentedMsg}`);
368
+ // Add statistics on the message to the report.
369
369
  const msgTextLC = msgText.toLowerCase();
370
370
  const msgLength = msgText.length;
371
371
  report.jobData.logCount++;
@@ -569,20 +569,12 @@ const goTo = async (report, page, url, timeout, waitUntil, isStrict) => {
569
569
  }
570
570
  // Visit the URL.
571
571
  const startTime = Date.now();
572
- const response = await page.goto(url, {
573
- timeout,
574
- waitUntil
575
- })
576
- .catch(error => {
577
- console.log(`ERROR: Visit to ${url} timed out before ${waitUntil} (${errorStart(error)})`);
578
- report.jobData.visitTimeoutCount++;
579
- return {
580
- error: 'timeout'
581
- };
582
- });
583
- report.jobData.visitLatency += Math.round((Date.now() - startTime) / 1000);
584
- // If the visit succeeded:
585
- if (! response.error) {
572
+ try {
573
+ const response = await page.goto(url, {
574
+ timeout,
575
+ waitUntil
576
+ });
577
+ report.jobData.visitLatency += Math.round((Date.now() - startTime) / 1000);
586
578
  const httpStatus = response.status();
587
579
  // If the response status was normal:
588
580
  if ([200, 304].includes(httpStatus) || url.startsWith('file:')) {
@@ -613,11 +605,10 @@ const goTo = async (report, page, url, timeout, waitUntil, isStrict) => {
613
605
  };
614
606
  }
615
607
  }
616
- // Otherwise, i.e. if the visit failed:
617
- else {
618
- // Return an error.
608
+ catch(error) {
609
+ console.log(`ERROR visiting ${url} (${error.message.slice(0, 200)})`);
619
610
  return {
620
- error: 'noStatus'
611
+ error: 'noVisit'
621
612
  };
622
613
  }
623
614
  };
package/tests/htmlcs.js CHANGED
@@ -26,6 +26,7 @@ exports.reporter = async (page, rules) => {
26
26
  // If only some rules are to be employed:
27
27
  if (rules && Array.isArray(rules) && rules.length) {
28
28
  // Redefine WCAG 2 AAA as including only them.
29
+ window.HTMLCS_WCAG2AAA ??= {};
29
30
  window.HTMLCS_WCAG2AAA.sniffs = rules;
30
31
  }
31
32
  // Run the tests.
package/tests/ibm.js CHANGED
@@ -25,14 +25,18 @@ const run = async (content, timeLimit) => {
25
25
  }, 1000 * timeLimit);
26
26
  });
27
27
  // Return the result of the test, or null if it timed out.
28
- const ibmReport = getCompliance(content, nowLabel)
29
- .catch(error => {
30
- console.log(`ERROR: getCompliance failed (${error.message.replace(/\n+/s, '')}).`);
28
+ try {
29
+ const ibmReport = await getCompliance(content, nowLabel);
30
+ const result = await Promise.race([ibmReport, timeout]);
31
+ clearTimeout(timeoutID);
32
+ return result;
33
+ }
34
+ catch(error) {
35
+ console.log(
36
+ `ERROR: getCompliance failed (${error.message.replace(/\s+/g, ' ').slice(0, 200)}).`
37
+ );
31
38
  return null;
32
- });
33
- const result = await Promise.race([ibmReport, timeout]);
34
- clearTimeout(timeoutID);
35
- return result;
39
+ }
36
40
  };
37
41
  // Revises report totals for any rule limitation.
38
42
  const limitRuleTotals = (report, rules) => {