@@ -112,10 +112,7 @@ class Reporter {
112
112
this . stdStream = stdStream ;
113
113
this . watching = watching ;
114
114
this . relativeFile = file => path . relative ( projectDir , file ) ;
115
- this . consumeStateChange = whileCorked (
116
- this . reportStream ,
117
- this . consumeStateChange
118
- ) ;
115
+ this . consumeStateChange = whileCorked ( this . reportStream , this . consumeStateChange ) ;
119
116
120
117
if ( this . verbose ) {
121
118
this . durationThreshold = durationThreshold || 100 ;
@@ -132,10 +129,7 @@ class Reporter {
132
129
stream : reportStream
133
130
} ) ;
134
131
this . lineWriter = new LineWriterWithSpinner ( this . reportStream , this . spinner ) ;
135
- this . endRun = whileCorked (
136
- this . reportStream ,
137
- whileCorked ( this . lineWriter , this . endRun )
138
- ) ;
132
+ this . endRun = whileCorked ( this . reportStream , whileCorked ( this . lineWriter , this . endRun ) ) ;
139
133
}
140
134
141
135
this . reset ( ) ;
@@ -334,8 +328,7 @@ class Reporter {
334
328
335
329
if ( this . verbose && ! this . filesWithMissingAvaImports . has ( event . testFile ) ) {
336
330
if ( event . nonZeroExitCode ) {
337
- this . lineWriter . writeLine ( colors . error ( `${ figures . cross } ${ this . relativeFile ( event . testFile ) } exited with a non-zero exit code: ${ event . nonZeroExitCode } ` )
338
- ) ;
331
+ this . lineWriter . writeLine ( colors . error ( `${ figures . cross } ${ this . relativeFile ( event . testFile ) } exited with a non-zero exit code: ${ event . nonZeroExitCode } ` ) ) ;
339
332
} else {
340
333
this . lineWriter . writeLine ( colors . error ( `${ figures . cross } ${ this . relativeFile ( event . testFile ) } exited due to ${ event . signal } ` ) ) ;
341
334
}
@@ -443,55 +436,24 @@ class Reporter {
443
436
string += os . EOL ;
444
437
}
445
438
446
- let firstLinePostfix = this . watching ?
447
- ' ' +
448
- chalk . gray . dim (
449
- '[' + new Date ( ) . toLocaleTimeString ( 'en-US' , { hour12 : false } ) + ']'
450
- ) :
451
- '' ;
439
+ let firstLinePostfix = this . watching ? ' ' + chalk . gray . dim ( '[' + new Date ( ) . toLocaleTimeString ( 'en-US' , { hour12 : false } ) + ']' ) : '' ;
452
440
453
441
if ( this . stats . passedTests > 0 ) {
454
- string +=
455
- os . EOL +
456
- colors . pass ( `${ this . stats . passedTests } passed` ) +
457
- firstLinePostfix ;
442
+ string += os . EOL + colors . pass ( `${ this . stats . passedTests } passed` ) + firstLinePostfix ;
458
443
firstLinePostfix = '' ;
459
444
}
460
445
461
446
if ( this . stats . passedKnownFailingTests > 0 ) {
462
- string +=
463
- os . EOL +
464
- colors . error (
465
- `${ this . stats . passedKnownFailingTests } ${ plur (
466
- 'known failure' ,
467
- this . stats . passedKnownFailingTests
468
- ) } `
469
- ) ;
447
+ string += os . EOL + colors . error ( `${ this . stats . passedKnownFailingTests } ${ plur ( 'known failure' , this . stats . passedKnownFailingTests ) } ` ) ;
470
448
}
471
449
472
450
if ( this . stats . failedHooks > 0 ) {
473
- string +=
474
- os . EOL +
475
- colors . error (
476
- `${ this . stats . failedHooks } ${ plur (
477
- 'hook' ,
478
- this . stats . failedHooks
479
- ) } failed`
480
- ) +
481
- firstLinePostfix ;
451
+ string += os . EOL + colors . error ( `${ this . stats . failedHooks } ${ plur ( 'hook' , this . stats . failedHooks ) } failed` ) + firstLinePostfix ;
482
452
firstLinePostfix = '' ;
483
453
}
484
454
485
455
if ( this . stats . failedTests > 0 ) {
486
- string +=
487
- os . EOL +
488
- colors . error (
489
- `${ this . stats . failedTests } ${ plur (
490
- 'test' ,
491
- this . stats . failedTests
492
- ) } failed`
493
- ) +
494
- firstLinePostfix ;
456
+ string += os . EOL + colors . error ( `${ this . stats . failedTests } ${ plur ( 'test' , this . stats . failedTests ) } failed` ) + firstLinePostfix ;
495
457
firstLinePostfix = '' ;
496
458
}
497
459
@@ -507,21 +469,15 @@ class Reporter {
507
469
}
508
470
509
471
writeErr ( event ) {
510
- if (
511
- event . err . name === 'TSError' &&
512
- event . err . object &&
513
- event . err . object . diagnosticText
514
- ) {
472
+ if ( event . err . name === 'TSError' && event . err . object && event . err . object . diagnosticText ) {
515
473
this . lineWriter . writeLine ( colors . errorStack ( trimOffNewlines ( event . err . object . diagnosticText ) ) ) ;
516
474
this . lineWriter . writeLine ( ) ;
517
475
return ;
518
476
}
519
477
520
478
if ( event . err . source ) {
521
479
this . lineWriter . writeLine ( colors . errorSource ( `${ this . relativeFile ( event . err . source . file ) } :${ event . err . source . line } ` ) ) ;
522
- const excerpt = codeExcerpt ( event . err . source , {
523
- maxWidth : this . reportStream . columns - 2
524
- } ) ;
480
+ const excerpt = codeExcerpt ( event . err . source , { maxWidth : this . reportStream . columns - 2 } ) ;
525
481
if ( excerpt ) {
526
482
this . lineWriter . writeLine ( ) ;
527
483
this . lineWriter . writeLine ( excerpt ) ;
@@ -636,9 +592,7 @@ class Reporter {
636
592
}
637
593
638
594
endRun ( ) { // eslint-disable-line complexity
639
- let firstLinePostfix = this . watching ?
640
- ` ${ chalk . gray . dim ( `[${ new Date ( ) . toLocaleTimeString ( 'en-US' , { hour12 : false } ) } ]` ) } ` :
641
- '' ;
595
+ let firstLinePostfix = this . watching ? ` ${ chalk . gray . dim ( `[${ new Date ( ) . toLocaleTimeString ( 'en-US' , { hour12 : false } ) } ]` ) } ` : '' ;
642
596
let wroteSomething = false ;
643
597
644
598
if ( ! this . verbose ) {
@@ -694,10 +648,7 @@ class Reporter {
694
648
695
649
if ( this . filesWithoutMatchedLineNumbers . size > 0 ) {
696
650
for ( const testFile of this . filesWithoutMatchedLineNumbers ) {
697
- if (
698
- ! this . filesWithMissingAvaImports . has ( testFile ) &&
699
- ! this . filesWithoutDeclaredTests . has ( testFile )
700
- ) {
651
+ if ( ! this . filesWithMissingAvaImports . has ( testFile ) && ! this . filesWithoutDeclaredTests . has ( testFile ) ) {
701
652
this . lineWriter . writeLine ( colors . error ( `${ figures . cross } Line numbers for ${ this . relativeFile ( testFile ) } did not match any tests` ) + firstLinePostfix ) ;
702
653
firstLinePostfix = '' ;
703
654
wroteSomething = true ;
@@ -714,10 +665,7 @@ class Reporter {
714
665
}
715
666
716
667
if ( this . failures . length > 0 ) {
717
- const writeTrailingLines =
718
- this . internalErrors . length > 0 ||
719
- this . uncaughtExceptions . length > 0 ||
720
- this . unhandledRejections . length > 0 ;
668
+ const writeTrailingLines = this . internalErrors . length > 0 || this . uncaughtExceptions . length > 0 || this . unhandledRejections . length > 0 ;
721
669
722
670
const lastFailure = this . failures [ this . failures . length - 1 ] ;
723
671
for ( const event of this . failures ) {
@@ -741,9 +689,7 @@ class Reporter {
741
689
742
690
if ( ! this . verbose ) {
743
691
if ( this . internalErrors . length > 0 ) {
744
- const writeTrailingLines =
745
- this . uncaughtExceptions . length > 0 ||
746
- this . unhandledRejections . length > 0 ;
692
+ const writeTrailingLines = this . uncaughtExceptions . length > 0 || this . unhandledRejections . length > 0 ;
747
693
748
694
const last = this . internalErrors [ this . internalErrors . length - 1 ] ;
749
695
for ( const event of this . internalErrors ) {
@@ -768,9 +714,7 @@ class Reporter {
768
714
if ( this . uncaughtExceptions . length > 0 ) {
769
715
const writeTrailingLines = this . unhandledRejections . length > 0 ;
770
716
771
- const last = this . uncaughtExceptions [
772
- this . uncaughtExceptions . length - 1
773
- ] ;
717
+ const last = this . uncaughtExceptions [ this . uncaughtExceptions . length - 1 ] ;
774
718
for ( const event of this . uncaughtExceptions ) {
775
719
this . lineWriter . writeLine ( colors . title ( `Uncaught exception in ${ this . relativeFile ( event . testFile ) } ` ) ) ;
776
720
this . lineWriter . writeLine ( ) ;
@@ -785,9 +729,7 @@ class Reporter {
785
729
}
786
730
787
731
if ( this . unhandledRejections . length > 0 ) {
788
- const last = this . unhandledRejections [
789
- this . unhandledRejections . length - 1
790
- ] ;
732
+ const last = this . unhandledRejections [ this . unhandledRejections . length - 1 ] ;
791
733
for ( const event of this . unhandledRejections ) {
792
734
this . lineWriter . writeLine ( colors . title ( `Unhandled rejection in ${ this . relativeFile ( event . testFile ) } ` ) ) ;
793
735
this . lineWriter . writeLine ( ) ;
@@ -807,30 +749,18 @@ class Reporter {
807
749
}
808
750
}
809
751
810
- if (
811
- this . failFastEnabled &&
812
- ( this . stats . remainingTests > 0 ||
813
- this . stats . files > this . stats . finishedWorkers )
814
- ) {
752
+ if ( this . failFastEnabled && ( this . stats . remainingTests > 0 || this . stats . files > this . stats . finishedWorkers ) ) {
815
753
let remaining = '' ;
816
754
if ( this . stats . remainingTests > 0 ) {
817
- remaining += `At least ${ this . stats . remainingTests } ${ plur (
818
- 'test was' ,
819
- 'tests were' ,
820
- this . stats . remainingTests
821
- ) } skipped`;
755
+ remaining += `At least ${ this . stats . remainingTests } ${ plur ( 'test was' , 'tests were' , this . stats . remainingTests ) } skipped` ;
822
756
if ( this . stats . files > this . stats . finishedWorkers ) {
823
757
remaining += ', as well as ' ;
824
758
}
825
759
}
826
760
827
761
if ( this . stats . files > this . stats . finishedWorkers ) {
828
762
const skippedFileCount = this . stats . files - this . stats . finishedWorkers ;
829
- remaining += `${ skippedFileCount } ${ plur (
830
- 'test file' ,
831
- 'test files' ,
832
- skippedFileCount
833
- ) } `;
763
+ remaining += `${ skippedFileCount } ${ plur ( 'test file' , 'test files' , skippedFileCount ) } ` ;
834
764
if ( this . stats . remainingTests === 0 ) {
835
765
remaining += ` ${ plur ( 'was' , 'were' , skippedFileCount ) } skipped` ;
836
766
}
0 commit comments