@@ -23,6 +23,9 @@ lolex.install(new Date(2014, 11, 19, 17, 19, 12, 200).getTime(), ['Date']);
2323const time = ' ' + chalk . grey . dim ( '[17:19:12]' ) ;
2424
2525function createReporter ( options ) {
26+ if ( options === undefined ) {
27+ options = { color : true } ;
28+ }
2629 const reporter = new VerboseReporter ( options ) ;
2730 return reporter ;
2831}
@@ -378,7 +381,7 @@ test('results with errors', t => {
378381 error2 . expected = JSON . stringify ( [ 2 ] ) ;
379382 error2 . expectedType = 'array' ;
380383
381- const reporter = createReporter ( { basePath : path . dirname ( err1Path ) } ) ;
384+ const reporter = createReporter ( { color : true , basePath : path . dirname ( err1Path ) } ) ;
382385 const runStatus = createRunStatus ( ) ;
383386 runStatus . failCount = 1 ;
384387 runStatus . tests = [ {
@@ -439,7 +442,7 @@ test('results with errors and disabled code excerpts', t => {
439442 error2 . expected = JSON . stringify ( [ 2 ] ) ;
440443 error2 . expectedType = 'array' ;
441444
442- const reporter = createReporter ( { basePath : path . dirname ( err2Path ) } ) ;
445+ const reporter = createReporter ( { color : true , basePath : path . dirname ( err2Path ) } ) ;
443446 const runStatus = createRunStatus ( ) ;
444447 runStatus . failCount = 1 ;
445448 runStatus . tests = [ {
@@ -499,7 +502,7 @@ test('results with errors and disabled code excerpts', t => {
499502 error2 . expected = JSON . stringify ( [ 2 ] ) ;
500503 error2 . expectedType = 'array' ;
501504
502- const reporter = createReporter ( { basePath : path . dirname ( err2Path ) } ) ;
505+ const reporter = createReporter ( { color : true , basePath : path . dirname ( err2Path ) } ) ;
503506 const runStatus = createRunStatus ( ) ;
504507 runStatus . failCount = 1 ;
505508 runStatus . tests = [ {
@@ -560,7 +563,7 @@ test('results with errors and disabled assert output', t => {
560563 error2 . expected = JSON . stringify ( [ 2 ] ) ;
561564 error2 . expectedType = 'array' ;
562565
563- const reporter = createReporter ( { basePath : path . dirname ( err1Path ) } ) ;
566+ const reporter = createReporter ( { color : true , basePath : path . dirname ( err1Path ) } ) ;
564567 const runStatus = createRunStatus ( ) ;
565568 runStatus . failCount = 1 ;
566569 runStatus . tests = [ {
@@ -602,7 +605,7 @@ test('results with errors and disabled assert output', t => {
602605} ) ;
603606
604607test ( 'results when fail-fast is enabled' , t => {
605- const reporter = new VerboseReporter ( ) ;
608+ const reporter = createReporter ( ) ;
606609 const runStatus = createRunStatus ( ) ;
607610 runStatus . remainingCount = 1 ;
608611 runStatus . failCount = 1 ;
@@ -626,7 +629,7 @@ test('results when fail-fast is enabled', t => {
626629} ) ;
627630
628631test ( 'results without fail-fast if no failing tests' , t => {
629- const reporter = new VerboseReporter ( ) ;
632+ const reporter = createReporter ( ) ;
630633 const runStatus = createRunStatus ( ) ;
631634 runStatus . remainingCount = 1 ;
632635 runStatus . failCount = 0 ;
@@ -645,7 +648,7 @@ test('results without fail-fast if no failing tests', t => {
645648} ) ;
646649
647650test ( 'results without fail-fast if no skipped tests' , t => {
648- const reporter = new VerboseReporter ( ) ;
651+ const reporter = createReporter ( ) ;
649652 const runStatus = createRunStatus ( ) ;
650653 runStatus . remainingCount = 0 ;
651654 runStatus . failCount = 1 ;
@@ -715,15 +718,15 @@ test('full-width line when sectioning', t => {
715718
716719test ( 'write calls console.error' , t => {
717720 const stub = sinon . stub ( console , 'error' ) ;
718- const reporter = new VerboseReporter ( ) ;
721+ const reporter = createReporter ( ) ;
719722 reporter . write ( 'result' ) ;
720723 t . true ( stub . called ) ;
721724 console . error . restore ( ) ;
722725 t . end ( ) ;
723726} ) ;
724727
725728test ( 'reporter.stdout and reporter.stderr both use process.stderr.write' , t => {
726- const reporter = new VerboseReporter ( ) ;
729+ const reporter = createReporter ( ) ;
727730 const stub = sinon . stub ( process . stderr , 'write' ) ;
728731 reporter . stdout ( 'result' ) ;
729732 reporter . stderr ( 'result' ) ;
@@ -733,7 +736,7 @@ test('reporter.stdout and reporter.stderr both use process.stderr.write', t => {
733736} ) ;
734737
735738test ( 'results when hasExclusive is enabled, but there are no known remaining tests' , t => {
736- const reporter = new VerboseReporter ( ) ;
739+ const reporter = createReporter ( ) ;
737740 const runStatus = createRunStatus ( ) ;
738741 runStatus . hasExclusive = true ;
739742 runStatus . passCount = 1 ;
@@ -750,7 +753,7 @@ test('results when hasExclusive is enabled, but there are no known remaining tes
750753} ) ;
751754
752755test ( 'results when hasExclusive is enabled, but there is one remaining tests' , t => {
753- const reporter = new VerboseReporter ( ) ;
756+ const reporter = createReporter ( ) ;
754757 const runStatus = createRunStatus ( ) ;
755758 runStatus . hasExclusive = true ;
756759 runStatus . testCount = 2 ;
@@ -773,7 +776,7 @@ test('results when hasExclusive is enabled, but there is one remaining tests', t
773776} ) ;
774777
775778test ( 'results when hasExclusive is enabled, but there are multiple remaining tests' , t => {
776- const reporter = new VerboseReporter ( ) ;
779+ const reporter = createReporter ( ) ;
777780 const runStatus = createRunStatus ( ) ;
778781 runStatus . hasExclusive = true ;
779782 runStatus . testCount = 3 ;
@@ -794,3 +797,26 @@ test('results when hasExclusive is enabled, but there are multiple remaining tes
794797 t . is ( output , expectedOutput ) ;
795798 t . end ( ) ;
796799} ) ;
800+
801+ test ( 'result when no-color flag is set' , t => {
802+ const reporter = new VerboseReporter ( { color : false } ) ;
803+ const runStatus = createRunStatus ( ) ;
804+ runStatus . hasExclusive = true ;
805+ runStatus . testCount = 3 ;
806+ runStatus . passCount = 1 ;
807+ runStatus . failCount = 0 ;
808+ runStatus . remainingCount = 2 ;
809+
810+ const output = reporter . finish ( runStatus ) ;
811+ const expectedOutput = [
812+ '' ,
813+ ' 1 test passed [17:19:12]' ,
814+ '' ,
815+ '' ,
816+ ' The .only() modifier is used in some tests. 2 tests were not run' ,
817+ ''
818+ ] . join ( '\n' ) ;
819+
820+ t . is ( output , expectedOutput ) ;
821+ t . end ( ) ;
822+ } ) ;
0 commit comments