1
1
require ( 'colors' ) ;
2
2
3
- var SpecReporter = function ( baseReporterDecorator , formatError , config ) {
3
+ var SpecReporter = function ( baseReporterDecorator , formatError , config ) {
4
4
baseReporterDecorator ( this ) ;
5
5
6
6
var reporterCfg = config . specReporter || { } ;
7
7
this . prefixes = reporterCfg . prefixes || {
8
- success : '✓ ' ,
9
- failure : '✗ ' ,
10
- skipped : '- ' ,
11
- } ;
8
+ success : '✓ ' ,
9
+ failure : '✗ ' ,
10
+ skipped : '- ' ,
11
+ } ;
12
12
13
13
if ( process && process . platform === 'win32' ) {
14
14
this . prefixes . success = '\u221A ' ;
@@ -33,9 +33,10 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
33
33
this . TOTAL_FAILED = 'TOTAL: %d FAILED, %d SUCCESS' . red + '\n' ;
34
34
}
35
35
36
- this . onRunComplete = function ( browsers , results ) {
36
+ this . onRunComplete = function ( browsers , results ) {
37
37
//NOTE: the renderBrowser function is defined in karma/reporters/Base.js
38
- this . writeCommonMsg ( '\n' + browsers . map ( this . renderBrowser ) . join ( '\n' ) + '\n' ) ;
38
+ this . writeCommonMsg ( '\n' + browsers . map ( this . renderBrowser )
39
+ . join ( '\n' ) + '\n' ) ;
39
40
40
41
if ( browsers . length >= 1 && ! results . disconnected && ! results . error ) {
41
42
if ( ! results . failed ) {
@@ -53,11 +54,11 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
53
54
this . currentSuite = [ ] ;
54
55
} ;
55
56
56
- this . logFinalErrors = function ( errors ) {
57
- this . writeCommonMsg ( '\n\n' ) ;
57
+ this . logFinalErrors = function ( errors ) {
58
+ this . writeCommonMsg ( '\n\n' ) ;
58
59
this . WHITESPACE = ' ' ;
59
60
60
- errors . forEach ( function ( failure , index ) {
61
+ errors . forEach ( function ( failure , index ) {
61
62
index = index + 1 ;
62
63
63
64
if ( index > 1 ) {
@@ -66,23 +67,24 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
66
67
67
68
this . writeCommonMsg ( ( index + ') ' + failure . description + '\n' ) . red ) ;
68
69
this . writeCommonMsg ( ( this . WHITESPACE + failure . suite . join ( ' ' ) + '\n' ) . red ) ;
69
- failure . log . forEach ( function ( log ) {
70
+ failure . log . forEach ( function ( log ) {
70
71
if ( reporterCfg . maxLogLines ) {
71
72
log = log . split ( '\n' ) . slice ( 0 , reporterCfg . maxLogLines ) . join ( '\n' ) ;
72
73
}
73
- this . writeCommonMsg ( this . WHITESPACE + formatError ( log ) . replace ( / \\ n / g, '\n' ) . grey ) ;
74
+ this . writeCommonMsg ( this . WHITESPACE + formatError ( log )
75
+ . replace ( / \\ n / g, '\n' ) . grey ) ;
74
76
} , this ) ;
75
77
} , this ) ;
76
78
77
- this . writeCommonMsg ( '\n' ) ;
79
+ this . writeCommonMsg ( '\n' ) ;
78
80
} ;
79
81
80
82
this . currentSuite = [ ] ;
81
- this . writeSpecMessage = function ( status ) {
82
- return ( function ( browser , result ) {
83
+ this . writeSpecMessage = function ( status ) {
84
+ return ( function ( browser , result ) {
83
85
var suite = result . suite ;
84
86
var indent = " " ;
85
- suite . forEach ( function ( value , index ) {
87
+ suite . forEach ( function ( value , index ) {
86
88
if ( index >= this . currentSuite . length || this . currentSuite [ index ] != value ) {
87
89
if ( index === 0 ) {
88
90
this . writeCommonMsg ( '\n' ) ;
@@ -100,14 +102,14 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
100
102
var specName = result . description ;
101
103
var elapsedTime = reporterCfg . showSpecTiming ? ' (' + result . time + 'ms)' : '' ;
102
104
103
- if ( this . USE_COLORS ) {
104
- if ( result . skipped ) specName = specName . cyan ;
105
- else if ( ! result . success ) specName = specName . red ;
105
+ if ( this . USE_COLORS ) {
106
+ if ( result . skipped ) specName = specName . cyan ;
107
+ else if ( ! result . success ) specName = specName . red ;
106
108
}
107
109
108
110
var msg = indent + status + specName + elapsedTime ;
109
111
110
- result . log . forEach ( function ( log ) {
112
+ result . log . forEach ( function ( log ) {
111
113
if ( reporterCfg . maxLogLines ) {
112
114
log = log . split ( '\n' ) . slice ( 0 , reporterCfg . maxLogLines ) . join ( '\n' ) ;
113
115
}
@@ -124,17 +126,19 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
124
126
125
127
this . LOG_SINGLE_BROWSER = '%s LOG: %s\n' ;
126
128
this . LOG_MULTI_BROWSER = '%s %s LOG: %s\n' ;
127
- this . onBrowserLog = function ( browser , log , type ) {
129
+ var doLog = config && config . browserConsoleLogOptions && config . browserConsoleLogOptions . terminal ;
130
+ this . onBrowserLog = doLog ? function ( browser , log , type ) {
128
131
if ( this . _browsers && this . _browsers . length === 1 ) {
129
132
this . write ( this . LOG_SINGLE_BROWSER , type . toUpperCase ( ) , this . USE_COLORS ? log . cyan : log ) ;
130
133
} else {
131
134
this . write ( this . LOG_MULTI_BROWSER , browser , type . toUpperCase ( ) , this . USE_COLORS ? log . cyan : log ) ;
132
135
}
133
- } ;
136
+ } : noop ;
134
137
138
+ function noop ( ) {
139
+ }
135
140
136
- function noop ( ) { }
137
- this . onSpecFailure = function ( browsers , results ) {
141
+ this . onSpecFailure = function ( browsers , results ) {
138
142
this . failures . push ( results ) ;
139
143
this . writeSpecMessage ( this . USE_COLORS ? this . prefixes . failure . red : this . prefixes . failure ) . apply ( this , arguments ) ;
140
144
if ( reporterCfg . failFast ) {
0 commit comments