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 +1 -1
- package/testaro/motion.js +0 -1
- package/tests/testaro.js +33 -17
package/package.json
CHANGED
package/testaro/motion.js
CHANGED
package/tests/testaro.js
CHANGED
|
@@ -142,7 +142,7 @@ const wait = ms => {
|
|
|
142
142
|
}, ms);
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
|
-
// Conducts and reports
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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:
|