@@ -10,33 +10,28 @@ module.exports = function () {
1010 var output = through ( )
1111 var test
1212
13- output . push ( LF )
14-
13+ output . push ( LF + splitter ( ' Tests ' ) )
1514 tap . on ( 'test' , function ( res ) {
1615 update ( )
17-
1816 test = {
1917 name : res . name ,
2018 pass : 0 ,
2119 fail : 0 ,
20+ get title ( ) {
21+ return this . name + ' [pass: ' + this . pass + ', fail: ' + this . fail + ']'
22+ } ,
2223 }
23- output . push ( format . cha . eraseLine . escape ( '# ' + res . name ) + LF )
24+ output . push ( LF + format . cha . eraseLine . escape ( '# ' + test . title ) )
2425 } )
2526
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 ) )
3230 } )
3331
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 ) )
4035 } )
4136
4237 tap . on ( 'output' , function ( res ) {
@@ -56,20 +51,9 @@ module.exports = function () {
5651 function update ( ) {
5752 if ( test ) {
5853 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 ) )
6655 } 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 ) )
7357 }
7458 }
7559 }
@@ -81,18 +65,17 @@ module.exports = function () {
8165function formatSummary ( res ) {
8266 var output = [ LF ]
8367 output . push ( splitter ( ' Summary ' ) )
84- output . push ( format . yellow . escape ( 'assertions: ' + res . asserts . length ) )
68+ output . push ( format . cyan . escape ( 'assertions: ' + res . asserts . length ) )
8569 if ( res . pass . length ) {
8670 output . push ( format . green . escape ( 'pass: ' + res . pass . length ) )
8771 } else {
88- output . push ( format . yellow . escape ( 'pass: ' + res . pass . length ) )
72+ output . push ( format . cyan . escape ( 'pass: ' + res . pass . length ) )
8973 }
9074 if ( res . fail . length ) {
9175 output . push ( format . red . escape ( 'fail: ' + res . fail . length ) )
9276 } else {
93- output . push ( format . yellow . escape ( 'fail: ' + res . fail . length ) )
77+ output . push ( format . cyan . escape ( 'fail: ' + res . fail . length ) )
9478 }
95- output . push ( repeat ( '=' , 80 ) )
9679 return output . join ( LF )
9780}
9881
@@ -106,17 +89,18 @@ function formatComment(res) {
10689 var output = [ LF ]
10790 output . push ( splitter ( ' Comments ' ) )
10891 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 ) )
11294 return output . join ( LF )
11395}
11496
11597function splitter ( s ) {
11698 var len = s && s . length || 0
11799 var max = 80
118100 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+ )
120104}
121105
122106function repeat ( str , n ) {
@@ -138,18 +122,19 @@ function getTest(n, tests) {
138122function formatFail ( res ) {
139123 var fail = res . fail . reduce ( function ( o , c ) {
140124 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 ) )
142127 o [ name ] . push ( prettifyError ( c ) )
143128 return o
144129 } , { } )
145130
146131 var output = [ LF ]
147132 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+ )
153138 return output . join ( LF )
154139}
155140
0 commit comments