Skip to content

Commit ff5c847

Browse files
committed
chore(branch): Merge branch 'PetroCloud-master'
2 parents 34ab2ba + 0265a8a commit ff5c847

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

index.js

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require('colors');
22

3-
var SpecReporter = function(baseReporterDecorator, formatError, config) {
3+
var SpecReporter = function (baseReporterDecorator, formatError, config) {
44
baseReporterDecorator(this);
55

66
var reporterCfg = config.specReporter || {};
77
this.prefixes = reporterCfg.prefixes || {
8-
success: '✓ ',
9-
failure: '✗ ',
10-
skipped: '- ',
11-
};
8+
success: '✓ ',
9+
failure: '✗ ',
10+
skipped: '- ',
11+
};
1212

1313
if (process && process.platform === 'win32') {
1414
this.prefixes.success = '\u221A ';
@@ -33,9 +33,10 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
3333
this.TOTAL_FAILED = 'TOTAL: %d FAILED, %d SUCCESS'.red + '\n';
3434
}
3535

36-
this.onRunComplete = function(browsers, results) {
36+
this.onRunComplete = function (browsers, results) {
3737
//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');
3940

4041
if (browsers.length >= 1 && !results.disconnected && !results.error) {
4142
if (!results.failed) {
@@ -53,11 +54,11 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
5354
this.currentSuite = [];
5455
};
5556

56-
this.logFinalErrors = function(errors) {
57-
this.writeCommonMsg('\n\n') ;
57+
this.logFinalErrors = function (errors) {
58+
this.writeCommonMsg('\n\n');
5859
this.WHITESPACE = ' ';
5960

60-
errors.forEach(function(failure, index) {
61+
errors.forEach(function (failure, index) {
6162
index = index + 1;
6263

6364
if (index > 1) {
@@ -66,23 +67,24 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
6667

6768
this.writeCommonMsg((index + ') ' + failure.description + '\n').red);
6869
this.writeCommonMsg((this.WHITESPACE + failure.suite.join(' ') + '\n').red);
69-
failure.log.forEach(function(log) {
70+
failure.log.forEach(function (log) {
7071
if (reporterCfg.maxLogLines) {
7172
log = log.split('\n').slice(0, reporterCfg.maxLogLines).join('\n');
7273
}
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);
7476
}, this);
7577
}, this);
7678

77-
this.writeCommonMsg('\n') ;
79+
this.writeCommonMsg('\n');
7880
};
7981

8082
this.currentSuite = [];
81-
this.writeSpecMessage = function(status) {
82-
return (function(browser, result) {
83+
this.writeSpecMessage = function (status) {
84+
return (function (browser, result) {
8385
var suite = result.suite;
8486
var indent = " ";
85-
suite.forEach(function(value, index) {
87+
suite.forEach(function (value, index) {
8688
if (index >= this.currentSuite.length || this.currentSuite[index] != value) {
8789
if (index === 0) {
8890
this.writeCommonMsg('\n');
@@ -100,14 +102,14 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
100102
var specName = result.description;
101103
var elapsedTime = reporterCfg.showSpecTiming ? ' (' + result.time + 'ms)' : '';
102104

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;
106108
}
107109

108110
var msg = indent + status + specName + elapsedTime;
109111

110-
result.log.forEach(function(log) {
112+
result.log.forEach(function (log) {
111113
if (reporterCfg.maxLogLines) {
112114
log = log.split('\n').slice(0, reporterCfg.maxLogLines).join('\n');
113115
}
@@ -124,17 +126,19 @@ var SpecReporter = function(baseReporterDecorator, formatError, config) {
124126

125127
this.LOG_SINGLE_BROWSER = '%s LOG: %s\n';
126128
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) {
128131
if (this._browsers && this._browsers.length === 1) {
129132
this.write(this.LOG_SINGLE_BROWSER, type.toUpperCase(), this.USE_COLORS ? log.cyan : log);
130133
} else {
131134
this.write(this.LOG_MULTI_BROWSER, browser, type.toUpperCase(), this.USE_COLORS ? log.cyan : log);
132135
}
133-
};
136+
} : noop;
134137

138+
function noop() {
139+
}
135140

136-
function noop(){}
137-
this.onSpecFailure = function(browsers, results) {
141+
this.onSpecFailure = function (browsers, results) {
138142
this.failures.push(results);
139143
this.writeSpecMessage(this.USE_COLORS ? this.prefixes.failure.red : this.prefixes.failure).apply(this, arguments);
140144
if (reporterCfg.failFast) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "karma-spec-reporter",
3-
"version": "0.0.28",
3+
"version": "0.0.29",
44
"description": "A Karma plugin. Report all spec-results to console (like mocha's spec reporter).",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)