testaro 5.5.8 → 5.5.9

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/create.js CHANGED
@@ -112,6 +112,7 @@ const runHosts = async (timeStamp, specs) => {
112
112
  if (crashHosts.length) {
113
113
  console.log(`Hosts crashed:\n${JSON.stringify(crashHosts, null, 2)}`);
114
114
  }
115
+ return '';
115
116
  }
116
117
  };
117
118
  // Runs a file-based job and writes a report file for the script or each host.
@@ -136,7 +137,7 @@ exports.runJob = async (scriptID, batchID) => {
136
137
  batch = JSON.parse(batchJSON);
137
138
  const specs = batchify(script, batch, timeStamp);
138
139
  // Recursively run each host script and save the reports.
139
- runHosts(timeStamp, specs);
140
+ await runHosts(timeStamp, specs);
140
141
  }
141
142
  // Otherwise, i.e. if there is no batch:
142
143
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.5.8",
3
+ "version": "5.5.9",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/runHost.js CHANGED
@@ -18,8 +18,29 @@ const runHost = async (id, scriptJSON, hostJSON) => {
18
18
  script: JSON.parse(scriptJSON),
19
19
  acts: []
20
20
  };
21
+ let reportJSON = JSON.stringify(report, null, 2);
21
22
  await handleRequest(report);
22
- const reportJSON = JSON.stringify(report, null, 2);
23
+ report.acts.forEach(act => {
24
+ try {
25
+ JSON.stringify(act);
26
+ }
27
+ catch (error) {
28
+ console.log(`ERROR: act of type ${act.type} malformatted`);
29
+ act = {
30
+ type: act.type || 'ERROR',
31
+ which: act.which || 'N/A',
32
+ prevented: true,
33
+ error: error.message
34
+ };
35
+ console.log(`act changed to:\n${JSON.stringify(act, null, 2)}`);
36
+ }
37
+ });
38
+ try {
39
+ reportJSON = JSON.stringify(report, null, 2);
40
+ }
41
+ catch(error) {
42
+ console.log(`ERROR: report for host ${id} not JSON (${error.message})`);
43
+ }
23
44
  process.send(reportJSON, () => {
24
45
  process.disconnect();
25
46
  process.exit();
package/tests/axe.js CHANGED
@@ -24,7 +24,7 @@ const {injectAxe, getAxeResults} = require('axe-playwright');
24
24
  // Conducts and reports an Axe test.
25
25
  exports.reporter = async (page, detailLevel, rules = []) => {
26
26
  // Initialize the report.
27
- const data = {};
27
+ let data = {};
28
28
  // Inject axe-core into the page.
29
29
  await injectAxe(page)
30
30
  .catch(error => {
@@ -104,5 +104,15 @@ exports.reporter = async (page, detailLevel, rules = []) => {
104
104
  }
105
105
  }
106
106
  // Return the result.
107
+ try {
108
+ JSON.stringify(data);
109
+ }
110
+ catch(error) {
111
+ console.log(`ERROR: axe result cannot be made JSON (${error.message})`);
112
+ data = {
113
+ prevented: true,
114
+ error: `ERROR: axe result cannot be made JSON (${error.message})`
115
+ };
116
+ }
107
117
  return {result: data};
108
118
  };