1
1
'use strict' ;
2
2
var prettyMs = require ( 'pretty-ms' ) ;
3
3
var figures = require ( 'figures' ) ;
4
- var chalk = require ( 'chalk ' ) ;
4
+ var colors = require ( '../colors ' ) ;
5
5
var plur = require ( 'plur' ) ;
6
6
var beautifyStack = require ( '../beautify-stack' ) ;
7
7
@@ -19,11 +19,11 @@ VerboseReporter.prototype.start = function () {
19
19
20
20
VerboseReporter . prototype . test = function ( test ) {
21
21
if ( test . error ) {
22
- return ' ' + chalk . red ( figures . cross ) + ' ' + test . title + ' ' + chalk . red ( test . error . message ) ;
22
+ return ' ' + colors . error ( figures . cross ) + ' ' + test . title + ' ' + colors . error ( test . error . message ) ;
23
23
}
24
24
25
25
if ( test . skip ) {
26
- return ' ' + chalk . cyan ( '- ' + test . title ) ;
26
+ return ' ' + colors . skip ( '- ' + test . title ) ;
27
27
}
28
28
29
29
if ( this . api . fileCount === 1 && this . api . testCount === 1 && test . title === '[anonymous]' ) {
@@ -32,9 +32,9 @@ VerboseReporter.prototype.test = function (test) {
32
32
33
33
// display duration only over a threshold
34
34
var threshold = 100 ;
35
- var duration = test . duration > threshold ? chalk . gray . dim ( ' (' + prettyMs ( test . duration ) + ')' ) : '' ;
35
+ var duration = test . duration > threshold ? colors . duration ( ' (' + prettyMs ( test . duration ) + ')' ) : '' ;
36
36
37
- return ' ' + chalk . green ( figures . tick ) + ' ' + test . title + duration ;
37
+ return ' ' + colors . pass ( figures . tick ) + ' ' + test . title + duration ;
38
38
} ;
39
39
40
40
VerboseReporter . prototype . unhandledError = function ( err ) {
@@ -43,12 +43,12 @@ VerboseReporter.prototype.unhandledError = function (err) {
43
43
exception : 'Uncaught Exception'
44
44
} ;
45
45
46
- var output = chalk . red ( types [ err . type ] + ':' , err . file ) + '\n' ;
46
+ var output = colors . error ( types [ err . type ] + ':' , err . file ) + '\n' ;
47
47
48
48
if ( err . stack ) {
49
- output += ' ' + chalk . red ( beautifyStack ( err . stack ) ) + '\n' ;
49
+ output += ' ' + colors . stack ( beautifyStack ( err . stack ) ) + '\n' ;
50
50
} else {
51
- output += ' ' + chalk . red ( JSON . stringify ( err ) ) + '\n' ;
51
+ output += ' ' + colors . stack ( JSON . stringify ( err ) ) + '\n' ;
52
52
}
53
53
54
54
output += '\n' ;
@@ -60,21 +60,21 @@ VerboseReporter.prototype.finish = function () {
60
60
var output = '\n' ;
61
61
62
62
if ( this . api . failCount > 0 ) {
63
- output += ' ' + chalk . red ( this . api . failCount , plur ( 'test' , this . api . failCount ) , 'failed' ) + '\n' ;
63
+ output += ' ' + colors . error ( this . api . failCount , plur ( 'test' , this . api . failCount ) , 'failed' ) + '\n' ;
64
64
} else {
65
- output += ' ' + chalk . green ( this . api . passCount , plur ( 'test' , this . api . passCount ) , 'passed' ) + '\n' ;
65
+ output += ' ' + colors . pass ( this . api . passCount , plur ( 'test' , this . api . passCount ) , 'passed' ) + '\n' ;
66
66
}
67
67
68
68
if ( this . api . skipCount > 0 ) {
69
- output += ' ' + chalk . yellow ( this . api . skipCount , plur ( 'test' , this . api . skipCount ) , 'skipped' ) + '\n' ;
69
+ output += ' ' + colors . skip ( this . api . skipCount , plur ( 'test' , this . api . skipCount ) , 'skipped' ) + '\n' ;
70
70
}
71
71
72
72
if ( this . api . rejectionCount > 0 ) {
73
- output += ' ' + chalk . red ( this . api . rejectionCount , 'unhandled' , plur ( 'rejection' , this . api . rejectionCount ) ) + '\n' ;
73
+ output += ' ' + colors . error ( this . api . rejectionCount , 'unhandled' , plur ( 'rejection' , this . api . rejectionCount ) ) + '\n' ;
74
74
}
75
75
76
76
if ( this . api . exceptionCount > 0 ) {
77
- output += ' ' + chalk . red ( this . api . exceptionCount , 'uncaught' , plur ( 'exception' , this . api . exceptionCount ) ) + '\n' ;
77
+ output += ' ' + colors . error ( this . api . exceptionCount , 'uncaught' , plur ( 'exception' , this . api . exceptionCount ) ) + '\n' ;
78
78
}
79
79
80
80
if ( this . api . failCount > 0 ) {
@@ -89,8 +89,8 @@ VerboseReporter.prototype.finish = function () {
89
89
90
90
i ++ ;
91
91
92
- output += ' ' + chalk . red ( i + '.' , test . title ) + '\n' ;
93
- output += ' ' + chalk . red ( beautifyStack ( test . error . stack ) ) + '\n' ;
92
+ output += ' ' + colors . error ( i + '.' , test . title ) + '\n' ;
93
+ output += ' ' + colors . stack ( beautifyStack ( test . error . stack ) ) + '\n' ;
94
94
} ) ;
95
95
}
96
96
0 commit comments