@@ -100,7 +100,7 @@ describe('SpecReporter', function () {
100
100
}
101
101
}
102
102
it ( 'SpecReporter should allow overriding success icon only' , function ( ) {
103
- var expected = 'PASS' ;
103
+ var expected = 'PASS' ;
104
104
var config = createConfigWithPrefixes ( { success : expected } ) ;
105
105
var newSpecReporter = createSpecReporter ( config ) ;
106
106
newSpecReporter . prefixes . success . should . equal ( expected ) ;
@@ -109,7 +109,7 @@ describe('SpecReporter', function () {
109
109
} ) ;
110
110
111
111
it ( 'SpecReporter should allow overriding failure icon only' , function ( ) {
112
- var expected = 'FAIL' ;
112
+ var expected = 'FAIL' ;
113
113
var config = createConfigWithPrefixes ( { failure : expected } ) ;
114
114
var newSpecReporter = createSpecReporter ( config ) ;
115
115
newSpecReporter . prefixes . success . should . equal ( windowsIcons . success ) ;
@@ -118,7 +118,7 @@ describe('SpecReporter', function () {
118
118
} ) ;
119
119
120
120
it ( 'SpecReporter should allow overriding skipped icon only' , function ( ) {
121
- var expected = 'SKIPPED' ;
121
+ var expected = 'SKIPPED' ;
122
122
var config = createConfigWithPrefixes ( { skipped : expected } ) ;
123
123
var newSpecReporter = createSpecReporter ( config ) ;
124
124
newSpecReporter . prefixes . success . should . equal ( windowsIcons . success ) ;
@@ -127,7 +127,7 @@ describe('SpecReporter', function () {
127
127
} ) ;
128
128
129
129
it ( 'SpecReporter should allow overriding all icons' , function ( ) {
130
- var config = createConfigWithPrefixes ( {
130
+ var config = createConfigWithPrefixes ( {
131
131
skipped : 'Skipped' ,
132
132
failure : 'Failed' ,
133
133
success : 'Win!'
@@ -397,6 +397,98 @@ describe('SpecReporter', function () {
397
397
} ) ;
398
398
} ) ;
399
399
400
+ describe ( 'logFinalErrors' , function ( ) {
401
+ var writtenMessages = [ ] ;
402
+ beforeEach ( function ( ) {
403
+ writtenMessages = [ ] ;
404
+ } ) ;
405
+ function passThrough ( str ) {
406
+ return str ;
407
+ }
408
+ function createSpecReporter ( options ) {
409
+ var result = new SpecReporter [ 1 ] ( baseReporterDecorator , passThrough , options || { } ) ;
410
+ result . writeCommonMsg = function ( str ) {
411
+ writtenMessages . push ( str ) ;
412
+ } ;
413
+ return result ;
414
+ }
415
+
416
+ it ( 'should write a single failure out' , function ( ) {
417
+ var errors = [
418
+ {
419
+ suite : [ 'A' , 'B' ] ,
420
+ description : 'should do stuff' ,
421
+ log : [
422
+ 'The Error!'
423
+ ]
424
+ }
425
+ ] ;
426
+ var expected = [ '\n\n' ,
427
+ '\u001b[31m1) should do stuff\n\u001b[39m' ,
428
+ '\u001b[31m A B\n\u001b[39m' ,
429
+ ' \u001b[90mThe Error!\u001b[39m' ,
430
+ '\n' ] ;
431
+ var specReporter = createSpecReporter ( ) ;
432
+ specReporter . logFinalErrors ( errors ) ;
433
+ writtenMessages . should . eql ( expected ) ;
434
+ } ) ;
435
+
436
+ it ( 'should truncate messages exceding maxLogLines in length' , function ( ) {
437
+ var errors = [
438
+ {
439
+ suite : [ 'A' , 'B' ] ,
440
+ description : 'should do stuff' ,
441
+ log : [
442
+ 'The Error!\nThis line should be discarded'
443
+ ]
444
+ }
445
+ ] ;
446
+ var expected = [ '\n\n' ,
447
+ '\u001b[31m1) should do stuff\n\u001b[39m' ,
448
+ '\u001b[31m A B\n\u001b[39m' ,
449
+ ' \u001b[90mThe Error!\u001b[39m' ,
450
+ '\n' ] ;
451
+ var specReporter = createSpecReporter ( {
452
+ specReporter : {
453
+ maxLogLines : 1
454
+ }
455
+ } ) ;
456
+ specReporter . logFinalErrors ( errors ) ;
457
+ writtenMessages . should . eql ( expected ) ;
458
+ } ) ;
459
+
460
+ it ( 'should write out multiple failures' , function ( ) {
461
+ var errors = [
462
+ {
463
+ suite : [ 'A' , 'B' ] ,
464
+ description : 'should do stuff' ,
465
+ log : [
466
+ 'The Error!'
467
+ ]
468
+ } ,
469
+ {
470
+ suite : [ 'C' , 'D' ] ,
471
+ description : 'should do more stuff' ,
472
+ log : [
473
+ 'Another error!'
474
+ ]
475
+ }
476
+ ] ;
477
+ var expected = [ '\n\n' ,
478
+ '\u001b[31m1) should do stuff\n\u001b[39m' ,
479
+ '\u001b[31m A B\n\u001b[39m' ,
480
+ ' \u001b[90mThe Error!\u001b[39m' ,
481
+ '\n' ,
482
+ '\u001b[31m2) should do more stuff\n\u001b[39m' ,
483
+ '\u001b[31m C D\n\u001b[39m' ,
484
+ ' \u001b[90mAnother error!\u001b[39m' ,
485
+ '\n' ] ;
486
+ var specReporter = createSpecReporter ( ) ;
487
+ specReporter . logFinalErrors ( errors ) ;
488
+ writtenMessages . should . eql ( expected ) ;
489
+ } ) ;
490
+ } ) ;
491
+
400
492
describe ( 'onSpecFailure' , function ( ) {
401
493
describe ( 'with FAIL_FAST option' , function ( ) {
402
494
var newSpecReporter ;
0 commit comments