testaro 32.2.2 → 32.3.3

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/README.md CHANGED
@@ -565,6 +565,8 @@ These changes were proposed as pull requests 1333 and 1334 (https://github.com/I
565
565
 
566
566
  The `ibm` tool is one of two tools (`testaro` is the other) with a `withItems` property. If you set `withItems` to `false`, the result includes the counts of “violations” and “recommendations”, but no information about the rules that gave rise to them.
567
567
 
568
+ Experimentation indicates that the `ibm` tools emits untrappable errors for some targets when the content argument given to it is the page content rather than the page URL. Therefore, it is safer to use `true` as the value of `withNewContent` for the `ibm` tool.
569
+
568
570
  ###### Nu Html Checker
569
571
 
570
572
  The `nuVal` tool performs the tests of the Nu Html Checker.
@@ -876,7 +878,7 @@ The rationales motivating the Testaro-defined tests can be found in comments wit
876
878
 
877
879
  ### Abnormal termination
878
880
 
879
- On rare occasions a test throws an error that terminates the Node process and cannot be handled with a `try`-`catch` structure. It has been observed, for example, that the `ibm` test does this when run on the host at `https://zenythgroup.com/index` or `https://monsido.com`.
881
+ On rare occasions a test throws an error that cannot be handled with a `try`-`catch` structure. It has been observed, for example, that the `ibm` test does this when the page content, rather than the page URL, is given to `getCompliance()` and the target is `https://globalsolutions.org` or `https://monsido.com`.
880
882
 
881
883
  ### Activation
882
884
 
package/actSpecs.js CHANGED
@@ -184,7 +184,7 @@ exports.actSpecs = {
184
184
  {
185
185
  withItems: [true, 'boolean', '', 'itemize'],
186
186
  withNewContent: [
187
- true, 'boolean', '', 'true: use a URL; false: use page content'
187
+ true, 'boolean', '', 'true: use a URL; false: use page content (risky)'
188
188
  ]
189
189
  }
190
190
  ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "32.2.2",
4
- "description": "Run 960 web accessibility tests from 9 tools and get a standardized report",
3
+ "version": "32.3.3",
4
+ "description": "Run 900 web accessibility tests from 9 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "tests": "node validation/executors/tests",
package/run.js CHANGED
@@ -422,10 +422,19 @@ const launch = async (report, typeName, url, debug, waits, isLowMotion = false)
422
422
  // Open a context (i.e. browser tab), with reduced motion if specified.
423
423
  const options = {reduceMotion: isLowMotion ? 'reduce' : 'no-preference'};
424
424
  const browserContext = await browser.newContext(options);
425
- // Prevent default timeouts, including those arising from a Playwright bug.
425
+ // Prevent default timeouts.
426
426
  browserContext.setDefaultTimeout(0);
427
427
  // When a page (i.e. browser tab) is added to the browser context (i.e. browser window):
428
428
  browserContext.on('page', async page => {
429
+ page.on('crash', () => {
430
+ console.log('Page crashed');
431
+ });
432
+ page.on('pageerror', () => {
433
+ console.log('Page erred');
434
+ });
435
+ page.on('requestfailed', () => {
436
+ console.log('Request failed');
437
+ });
429
438
  // If it emits a message:
430
439
  page.on('console', msg => {
431
440
  const msgText = msg.text();
@@ -23,8 +23,7 @@
23
23
  /*
24
24
  headingAmb
25
25
  Related to ASLint rule headings-sibling-unique.
26
- This test reports same-level heading siblings in the heading hierarchy that have identical text
27
- contents.
26
+ This test reports adjacent headings with the same levels and text contents.
28
27
  */
29
28
 
30
29
  // ########## IMPORTS
@@ -49,21 +48,24 @@ exports.reporter = async (page, withItems) => {
49
48
  const badIndexes = [];
50
49
  // For each heading:
51
50
  headings.forEach((heading, index) => {
52
- // If any same-level and same-text heading precedes it:
53
- const priors = headings.slice(0, index);
54
- priors.forEach((prior, priorIndex) => {
51
+ // Get its level.
52
+ const level = heading.level;
53
+ // If there are prior non-inferior headings and the last one has the same-level and text:
54
+ // Get the prior headings.
55
+ const priorHeadings = headings.slice(0, index);
56
+ // Get the non-inferior ones among them.
57
+ const nonInferiors = priorHeadings.filter(priorHeading => priorHeading.level <= level);
58
+ // If there are any:
59
+ const nonInferiorCount = nonInferiors.length;
60
+ if (nonInferiorCount) {
61
+ // Get the last of them.
62
+ const prior = nonInferiors[nonInferiorCount - 1];
63
+ // If they have the same level and text:
55
64
  if (['tagName', 'textContent'].every(property => prior[property] === heading[property])) {
56
- // If no superior heading exists between them:
57
- if (
58
- headings
59
- .slice(priorIndex + 1, index)
60
- .every(betweenHeading => betweenHeading.tagName[1] >= heading.tagName[1])
61
- ) {
62
- // Add the index of the later heading to the index of violating headings.
63
- badIndexes.push(headings.indexOf(heading));
64
- }
65
+ // Add the index of the later heading to the index of violating headings.
66
+ badIndexes.push(index);
65
67
  }
66
- });
68
+ }
67
69
  });
68
70
  return badIndexes;
69
71
  });
package/tests/ibm.js CHANGED
@@ -41,27 +41,18 @@ const {getCompliance} = require('accessibility-checker');
41
41
  // FUNCTIONS
42
42
 
43
43
  // Runs the IBM test and returns the result.
44
- const run = async (content, timeLimit) => {
44
+ const run = async content => {
45
45
  const nowLabel = (new Date()).toISOString().slice(0, 19);
46
- // Start the timeout clock.
47
- let timeoutID;
48
- const timeout = new Promise(resolve => {
49
- timeoutID = setTimeout(() => {
50
- resolve(null);
51
- }, 1000 * timeLimit);
52
- });
53
- // Return the result of the test, or null if it timed out.
54
46
  try {
55
- const ibmReport = getCompliance(content, nowLabel);
56
- const result = await Promise.race([ibmReport, timeout]);
57
- clearTimeout(timeoutID);
58
- return result;
47
+ const ibmReport = await getCompliance(content, nowLabel);
48
+ return ibmReport;
59
49
  }
60
50
  catch(error) {
61
- console.log(
62
- `ERROR: getCompliance failed (${error.message.replace(/\s+/g, ' ').slice(0, 200)}).`
63
- );
64
- return null;
51
+ console.log('ibm getCompliance failed');
52
+ return {
53
+ prevented: true,
54
+ error: error.message.slice(0, 200)
55
+ };
65
56
  }
66
57
  };
67
58
  // Revises act-report totals for any rule limitation.
@@ -114,8 +105,10 @@ const trimActReport = (data, actReport, withItems, rules) => {
114
105
  // Otherwise, i.e. if it excludes totals:
115
106
  else {
116
107
  // Report this.
108
+ const error = 'ERROR: No totals reported';
109
+ console.log(error);
117
110
  data.prevented = true;
118
- data.error = 'ERROR: No totals reported';
111
+ data.error = error;
119
112
  // Return an empty act report.
120
113
  return {
121
114
  totals: {},
@@ -126,8 +119,10 @@ const trimActReport = (data, actReport, withItems, rules) => {
126
119
  // Otherwise, i.e. if it excludes a summary:
127
120
  else {
128
121
  // Report this.
122
+ const error = 'ERROR: No summary reported';
123
+ console.log(error);
129
124
  data.prevented = true;
130
- data.error = 'ERROR: No summary reported';
125
+ data.error = error;
131
126
  // Return an empty act report.
132
127
  return {
133
128
  totals: {},
@@ -137,27 +132,38 @@ const trimActReport = (data, actReport, withItems, rules) => {
137
132
  };
138
133
  // Performs the IBM tests and returns an act report.
139
134
  const doTest = async (content, withItems, timeLimit, rules) => {
140
- // Conduct the test and get the result.
135
+ // Conduct the tests.
141
136
  const data = {};
142
137
  try {
143
138
  const runReport = await run(content, timeLimit);
144
- const actReport = runReport && runReport.report;
145
- // Delete any report files.
146
- try {
147
- const reportNames = await fs.readdir('ibmOutput');
148
- for (const reportName of reportNames) {
149
- await fs.rm(`ibmOutput/${reportName}`);
139
+ // If there were results:
140
+ if (runReport.report) {
141
+ // Delete any report files.
142
+ try {
143
+ const reportNames = await fs.readdir('ibmOutput');
144
+ for (const reportName of reportNames) {
145
+ await fs.rm(`ibmOutput/${reportName}`);
146
+ }
150
147
  }
148
+ catch(error) {
149
+ console.log('No result files created');
150
+ };
151
+ // Return a trimmed act report.
152
+ const {report} = runReport;
153
+ const trimmedReport = trimActReport(data, report, withItems, rules);
154
+ return {
155
+ data,
156
+ result: trimmedReport
157
+ };
151
158
  }
152
- catch(error) {
153
- console.log('No result files created');
159
+ // Otherwise, i.e. if there were no results:
160
+ else {
161
+ // Return this.
162
+ return {
163
+ data: runReport,
164
+ result: {}
165
+ }
154
166
  }
155
- // Return a trimmed act report.
156
- const trimmedReport = trimActReport(data, actReport, withItems, rules);
157
- return {
158
- data,
159
- result: trimmedReport
160
- };
161
167
  }
162
168
  catch(error) {
163
169
  const message = `Act failed (${error.message.slice(0, 200)})`;
@@ -186,6 +192,7 @@ exports.reporter = async (page, options) => {
186
192
  const message = `ERROR: Act failed or timed out at ${timeLimit} seconds`;
187
193
  console.log(message);
188
194
  data.error = data.error ? `${data.error}; ${message}` : message;
195
+ // Return the failure.
189
196
  return {
190
197
  data,
191
198
  result: {}