@@ -3,13 +3,15 @@ var duplexer = require('duplexer2')
3
3
var parser = require ( 'tap-out' )
4
4
var format = require ( 'ansi-escape' )
5
5
var symbols = require ( 'figures' )
6
+ var prettyMs = require ( 'pretty-ms' )
6
7
var LF = '\n'
7
8
8
9
module . exports = function ( ) {
9
10
var tap = parser ( )
10
11
var output = through ( )
11
12
var test
12
13
14
+ var duration = 0
13
15
output . push ( LF + splitter ( ' Tests ' ) )
14
16
tap . on ( 'test' , function ( res ) {
15
17
update ( )
@@ -18,8 +20,14 @@ module.exports = function () {
18
20
pass : 0 ,
19
21
fail : 0 ,
20
22
get title ( ) {
21
- return this . name + ' [pass: ' + this . pass + ', fail: ' + this . fail + ']'
23
+ return this . name +
24
+ ' [' +
25
+ 'pass: ' + this . pass +
26
+ ', fail: ' + this . fail +
27
+ ( test . end ? ', duration: ' + prettyMs ( test . duration ) : '' ) +
28
+ ']'
22
29
} ,
30
+ start : new Date ( ) ,
23
31
}
24
32
output . push ( LF + format . cha . eraseLine . escape ( '# ' + test . title ) )
25
33
} )
@@ -36,7 +44,7 @@ module.exports = function () {
36
44
37
45
tap . on ( 'output' , function ( res ) {
38
46
update ( )
39
- output . push ( formatSummary ( res ) )
47
+ output . push ( formatSummary ( res , { duration : duration } ) )
40
48
if ( res . fail . length ) {
41
49
dup . failed = true
42
50
output . push ( formatFail ( res ) )
@@ -50,6 +58,9 @@ module.exports = function () {
50
58
51
59
function update ( ) {
52
60
if ( test ) {
61
+ test . end = new Date ( )
62
+ test . duration = test . end - test . start
63
+ duration += test . duration
53
64
if ( test . fail ) {
54
65
output . push ( format . cha . red . eraseLine . escape ( symbols . cross + ' ' + test . title ) )
55
66
} else {
@@ -62,9 +73,10 @@ module.exports = function () {
62
73
return dup
63
74
}
64
75
65
- function formatSummary ( res ) {
76
+ function formatSummary ( res , extra ) {
66
77
var output = [ LF ]
67
78
output . push ( splitter ( ' Summary ' ) )
79
+ output . push ( format . cyan . escape ( 'duration: ' + prettyMs ( extra . duration ) ) )
68
80
output . push ( format . cyan . escape ( 'assertions: ' + res . asserts . length ) )
69
81
if ( res . pass . length ) {
70
82
output . push ( format . green . escape ( 'pass: ' + res . pass . length ) )
0 commit comments