testaro 36.2.0 → 36.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "36.2.0",
3
+ "version": "36.3.0",
4
4
  "description": "Run 1000 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/testaro/motion.js CHANGED
@@ -51,7 +51,6 @@ exports.reporter = async page => {
51
51
  delayBefore: 2000,
52
52
  delayBetween: 3000
53
53
  });
54
- console.log(JSON.stringify(data, null, 2));
55
54
  // If the screenshots succeeded:
56
55
  if (data.success) {
57
56
  // If any pixels were changed:
package/tests/testaro.js CHANGED
@@ -142,7 +142,7 @@ const wait = ms => {
142
142
  }, ms);
143
143
  });
144
144
  };
145
- // Conducts and reports the Testaro tests.
145
+ // Conducts and reports Testaro tests.
146
146
  exports.reporter = async (page, options) => {
147
147
  const {report, withItems, stopOnFail, args} = options;
148
148
  const argRules = args ? Object.keys(args) : null;
@@ -208,23 +208,39 @@ exports.reporter = async (page, options) => {
208
208
  result[rule].what = what;
209
209
  try {
210
210
  const startTime = Date.now();
211
- const ruleReport = isJS
212
- ? await require(`../testaro/${rule}`).reporter(... ruleArgs)
213
- : await jsonTest(rule, ruleArgs);
214
- // Add data from the test to the result.
215
- const endTime = Date.now();
216
- testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
217
- Object.keys(ruleReport).forEach(key => {
218
- result[rule][key] = ruleReport[key];
211
+ // Apply a 9-second time limit to the test. If it expires:
212
+ let timeout;
213
+ const timer = new Promise(resolve => {
214
+ timeout = setTimeout(() => {
215
+ // Add data about the test, including its prevention, to the result.
216
+ const endTime = Date.now();
217
+ testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
218
+ data.rulePreventions.push(rule);
219
+ result[rule].totals = [0, 0, 0, 0];
220
+ result[rule].standardInstances = [];
221
+ console.log(`ERROR: Test of testaro rule ${rule} timed out`);
222
+ resolve({timedOut: true});
223
+ }, 9000);
219
224
  });
220
- result[rule].totals = result[rule].totals.map(total => Math.round(total));
221
- if (ruleReport.prevented) {
222
- data.rulePreventions.push(rule);
223
- }
224
- // If testing is to stop after a failure and the page failed the test:
225
- if (stopOnFail && ruleReport.totals.some(total => total)) {
226
- // Stop testing.
227
- break;
225
+ const ruleReport = isJS
226
+ ? require(`../testaro/${rule}`).reporter(... ruleArgs)
227
+ : jsonTest(rule, ruleArgs);
228
+ const timeoutReport = await Promise.race([timer, ruleReport]);
229
+ clearTimeout(timeout);
230
+ // If the test was completed before the deadline:
231
+ if (! timeoutReport.timedOut) {
232
+ // Add data from the test to the result.
233
+ const endTime = Date.now();
234
+ testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
235
+ Object.keys(timeoutReport).forEach(key => {
236
+ result[rule][key] = timeoutReport[key];
237
+ });
238
+ result[rule].totals = result[rule].totals.map(total => Math.round(total));
239
+ // If testing is to stop after a failure and the page failed the test:
240
+ if (stopOnFail && timeoutReport.totals.some(total => total)) {
241
+ // Stop testing.
242
+ break;
243
+ }
228
244
  }
229
245
  }
230
246
  // If an error is thrown by the test: