11'use strict' ;
22var prettyMs = require ( 'pretty-ms' ) ;
33var figures = require ( 'figures' ) ;
4- var chalk = require ( 'chalk ' ) ;
4+ var colors = require ( '../colors ' ) ;
55var plur = require ( 'plur' ) ;
66var beautifyStack = require ( '../beautify-stack' ) ;
77
@@ -19,11 +19,11 @@ VerboseReporter.prototype.start = function () {
1919
2020VerboseReporter . prototype . test = function ( test ) {
2121 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 ) ;
2323 }
2424
2525 if ( test . skip ) {
26- return ' ' + chalk . cyan ( '- ' + test . title ) ;
26+ return ' ' + colors . skip ( '- ' + test . title ) ;
2727 }
2828
2929 if ( this . api . fileCount === 1 && this . api . testCount === 1 && test . title === '[anonymous]' ) {
@@ -32,9 +32,9 @@ VerboseReporter.prototype.test = function (test) {
3232
3333 // display duration only over a threshold
3434 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 ) + ')' ) : '' ;
3636
37- return ' ' + chalk . green ( figures . tick ) + ' ' + test . title + duration ;
37+ return ' ' + colors . pass ( figures . tick ) + ' ' + test . title + duration ;
3838} ;
3939
4040VerboseReporter . prototype . unhandledError = function ( err ) {
@@ -43,12 +43,12 @@ VerboseReporter.prototype.unhandledError = function (err) {
4343 exception : 'Uncaught Exception'
4444 } ;
4545
46- var output = chalk . red ( types [ err . type ] + ':' , err . file ) + '\n' ;
46+ var output = colors . error ( types [ err . type ] + ':' , err . file ) + '\n' ;
4747
4848 if ( err . stack ) {
49- output += ' ' + chalk . red ( beautifyStack ( err . stack ) ) + '\n' ;
49+ output += ' ' + colors . stack ( beautifyStack ( err . stack ) ) + '\n' ;
5050 } else {
51- output += ' ' + chalk . red ( JSON . stringify ( err ) ) + '\n' ;
51+ output += ' ' + colors . stack ( JSON . stringify ( err ) ) + '\n' ;
5252 }
5353
5454 output += '\n' ;
@@ -60,21 +60,21 @@ VerboseReporter.prototype.finish = function () {
6060 var output = '\n' ;
6161
6262 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' ;
6464 } 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' ;
6666 }
6767
6868 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' ;
7070 }
7171
7272 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' ;
7474 }
7575
7676 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' ;
7878 }
7979
8080 if ( this . api . failCount > 0 ) {
@@ -89,8 +89,8 @@ VerboseReporter.prototype.finish = function () {
8989
9090 i ++ ;
9191
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' ;
9494 } ) ;
9595 }
9696
0 commit comments