@@ -10,33 +10,28 @@ module.exports = function () {
10
10
var output = through ( )
11
11
var test
12
12
13
- output . push ( LF )
14
-
13
+ output . push ( LF + splitter ( ' Tests ' ) )
15
14
tap . on ( 'test' , function ( res ) {
16
15
update ( )
17
-
18
16
test = {
19
17
name : res . name ,
20
18
pass : 0 ,
21
19
fail : 0 ,
20
+ get title ( ) {
21
+ return this . name + ' [pass: ' + this . pass + ', fail: ' + this . fail + ']'
22
+ } ,
22
23
}
23
- output . push ( format . cha . eraseLine . escape ( '# ' + res . name ) + LF )
24
+ output . push ( LF + format . cha . eraseLine . escape ( '# ' + test . title ) )
24
25
} )
25
26
26
- tap . on ( 'pass' , function ( res ) {
27
- test . pass ++
28
- output . push (
29
- format . cha . eraseLine ( 2 ) . escape ( ) +
30
- ' ok ' + format . green . bold . escape ( res . number ) + ' ' + res . name
31
- )
27
+ tap . on ( 'pass' , function ( ) {
28
+ ++ test . pass
29
+ output . push ( format . cha . eraseLine . escape ( '# ' + test . title ) )
32
30
} )
33
31
34
- tap . on ( 'fail' , function ( res ) {
35
- test . fail ++
36
- output . push (
37
- format . cha . eraseLine ( 2 ) . escape ( ) +
38
- ' not ok ' + format . red . bold . escape ( res . number ) + ' ' + res . name
39
- )
32
+ tap . on ( 'fail' , function ( ) {
33
+ ++ test . fail
34
+ output . push ( format . cha . eraseLine . escape ( '# ' + test . title ) )
40
35
} )
41
36
42
37
tap . on ( 'output' , function ( res ) {
@@ -56,20 +51,9 @@ module.exports = function () {
56
51
function update ( ) {
57
52
if ( test ) {
58
53
if ( test . fail ) {
59
- output . push (
60
- format . up . cha . red . escape (
61
- symbols . cross + ' ' + test . name +
62
- ' (pass: ' + test . pass + ', fail: ' + test . fail + ')'
63
- ) +
64
- format . down . cha . eraseLine . escape ( )
65
- )
54
+ output . push ( format . cha . red . eraseLine . escape ( symbols . cross + ' ' + test . title ) )
66
55
} else {
67
- output . push (
68
- format . up . cha . green . escape (
69
- symbols . tick + ' ' + test . name + ' (' + test . pass + ')'
70
- ) +
71
- format . down . cha . eraseLine . escape ( )
72
- )
56
+ output . push ( format . cha . green . eraseLine . escape ( symbols . tick + ' ' + test . title ) )
73
57
}
74
58
}
75
59
}
@@ -81,18 +65,17 @@ module.exports = function () {
81
65
function formatSummary ( res ) {
82
66
var output = [ LF ]
83
67
output . push ( splitter ( ' Summary ' ) )
84
- output . push ( format . yellow . escape ( 'assertions: ' + res . asserts . length ) )
68
+ output . push ( format . cyan . escape ( 'assertions: ' + res . asserts . length ) )
85
69
if ( res . pass . length ) {
86
70
output . push ( format . green . escape ( 'pass: ' + res . pass . length ) )
87
71
} else {
88
- output . push ( format . yellow . escape ( 'pass: ' + res . pass . length ) )
72
+ output . push ( format . cyan . escape ( 'pass: ' + res . pass . length ) )
89
73
}
90
74
if ( res . fail . length ) {
91
75
output . push ( format . red . escape ( 'fail: ' + res . fail . length ) )
92
76
} else {
93
- output . push ( format . yellow . escape ( 'fail: ' + res . fail . length ) )
77
+ output . push ( format . cyan . escape ( 'fail: ' + res . fail . length ) )
94
78
}
95
- output . push ( repeat ( '=' , 80 ) )
96
79
return output . join ( LF )
97
80
}
98
81
@@ -106,17 +89,18 @@ function formatComment(res) {
106
89
var output = [ LF ]
107
90
output . push ( splitter ( ' Comments ' ) )
108
91
output . push ( Object . keys ( comments ) . map ( function ( name ) {
109
- return format . yellow . escape ( name ) + LF + comments [ name ] . join ( LF )
110
- } ) . join ( LF ) )
111
- output . push ( splitter ( ) )
92
+ return format . cyan . underline . escape ( name ) + LF + comments [ name ] . join ( LF )
93
+ } ) . join ( LF + LF ) )
112
94
return output . join ( LF )
113
95
}
114
96
115
97
function splitter ( s ) {
116
98
var len = s && s . length || 0
117
99
var max = 80
118
100
var left = max - len >> 1
119
- return repeat ( '=' , left ) + ( s || '' ) + repeat ( '=' , max - len - left )
101
+ return format . yellow . escape (
102
+ repeat ( '-' , left ) + ( s || '' ) + repeat ( '-' , max - len - left )
103
+ )
120
104
}
121
105
122
106
function repeat ( str , n ) {
@@ -138,18 +122,19 @@ function getTest(n, tests) {
138
122
function formatFail ( res ) {
139
123
var fail = res . fail . reduce ( function ( o , c ) {
140
124
var name = getTest ( c . test , res . tests ) . name
141
- o [ name ] = o [ name ] || [ ]
125
+ o [ name ] = o [ name ] || [ format . cyan . underline . escape ( '# ' + name ) ]
126
+ o [ name ] . push ( format . red . escape ( ' ' + symbols . cross + ' ' + c . name ) )
142
127
o [ name ] . push ( prettifyError ( c ) )
143
128
return o
144
129
} , { } )
145
130
146
131
var output = [ LF ]
147
132
output . push ( splitter ( ' Fails ' ) )
148
- Object . keys ( fail ) . forEach ( function ( name ) {
149
- output . push ( format . red . escape ( symbols . cross + ' ' + name ) )
150
- output . push ( fail [ name ] . join ( LF + ' ' + repeat ( '-' , 76 ) + LF ) )
151
- } )
152
- output . push ( repeat ( '=' , 80 ) )
133
+ output . push (
134
+ Object . keys ( fail ) . map ( function ( name ) {
135
+ return fail [ name ] . join ( LF )
136
+ } ) . join ( LF + LF )
137
+ )
153
138
return output . join ( LF )
154
139
}
155
140
0 commit comments