-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
54 lines (46 loc) · 1.23 KB
/
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { execFile } = require('child_process')
const path = require('path')
const suites = [
'./first-module/first-suite.js',
'./second-module/second-suite.js'
]
const promises = suites.map((suite) => new Promise((resolve, reject) => {
execFile('node', [path.join(__dirname, suite)], (error, stdout, stderr) => {
if (error) {
return reject(error)
}
try {
resolve({ suite, events: JSON.parse(stdout).map((row) => row.event) })
} catch (e) {
e.stdout = stdout
throw e
}
})
}))
Promise.all(promises)
.then((results) => {
const errors = []
const rows = results
.map((result) => {
const endEvent = result.events.find((event) => event.type === 'END')
if (endEvent.totals.failed > 0) {
errors.push(result)
}
return {
suite: result.suite,
total: endEvent.totals.total,
passed: endEvent.totals.passed,
failed: endEvent.totals.failed,
broken: endEvent.totals.broken,
skipped: endEvent.totals.skipped
}
})
console.table(rows)
if (errors.length) {
console.log(errors)
process.exit(1)
}
}).catch((err) => {
console.log(err)
process.exit(1)
})