-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (47 loc) · 1.26 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
55
56
57
58
var Rx = require('rx')
var format = require('chalk')
var prettyMs = require('pretty-ms')
var hirestime = require('hirestime')
module.exports = function (input$) {
var timer = hirestime()
var output$ = new Rx.Subject()
// Output the results
input$.results$
.forEach(
function (line) {
switch (line.name) {
case 'tests': {
output$.onNext(pad('assertions: ' + line.count))
break
}
case 'pass': {
output$.onNext(pad(format.green('passing: ' + line.count)))
break
}
case 'fail': {
if (line.count > 0) {
output$.onNext(pad(format.red('failing: ' + line.count)))
}
break
}
}
},
function () {
output$.onNext('\n')
output$.onNext(
format.red.bold('PARSING ERROR:'),
'There was an error in the TAP parsing. Please open an issue at',
format.underline('https://github.com/scottcorgan/tap-out/issues.')
)
},
function () {
output$.onNext(pad('duration: ' + prettyMs(timer())))
output$.onNext('\n')
}
)
return output$
}
function pad (str) {
str = str || ''
return ' ' + str
}