forked from HowProgrammingWorks/IntegrationTesting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.js
More file actions
34 lines (32 loc) · 791 Bytes
/
runner.js
File metadata and controls
34 lines (32 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const start = (tests) => {
let failed = 0;
const count = tests.length;
const runNext = () => {
if (tests.length === 0) {
console.log(`Total: ${count}; Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
return;
}
const test = tests.shift();
console.log(`Started test: ${test.name}`);
try {
test((err) => {
if (err) {
failed++;
console.log(`Failed test: ${test.name}`);
console.log(err);
}
console.log(`Finished test: ${test.name}`);
setTimeout(runNext, 0);
});
} catch (err) {
failed++;
console.log(`Failed test: ${test.name}`);
console.log(err);
setTimeout(runNext, 0);
}
};
runNext();
};
module.exports = { start };