Skip to content

Commit

Permalink
Merge pull request #80 from squarebracket/master
Browse files Browse the repository at this point in the history
add showBrowser config option to print browser for each spec
  • Loading branch information
tmcgee123 committed Apr 11, 2022
2 parents 58d6e40 + 98718cf commit b7a0051
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ karma.conf.js file
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showBrowser: false, // print the browser for each spec
showSpecTiming: false, // print the time elapsed for each spec
failFast: true, // test would finish with error when a first fail occurs
prefixes: {
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ var SpecReporter = function (baseReporterDecorator, formatError, config) {
this.currentSuite = suite;

var specName = result.description;
var browserName = reporterCfg.showBrowser ? ' [' + browser.name + ']' : '';
var elapsedTime = reporterCfg.showSpecTiming ? ' (' + result.time + 'ms)' : '';

if (this.reportSlowerThan && result.time > config.reportSlowerThan) {
Expand All @@ -150,7 +151,7 @@ var SpecReporter = function (baseReporterDecorator, formatError, config) {
else if (!result.success) specName = specName.red;
}

var msg = indent + status + specName + elapsedTime;
var msg = indent + status + specName + browserName + elapsedTime;

result.log.forEach(function (log) {
if (reporterCfg.maxLogLines) {
Expand Down Expand Up @@ -203,6 +204,7 @@ var SpecReporter = function (baseReporterDecorator, formatError, config) {
this.suppressSummary = reporterCfg.suppressSummary || false;
this.suppressErrorSummary = reporterCfg.suppressErrorSummary || false;
this.showSpecTiming = reporterCfg.showSpecTiming || false;
this.showBrowser = reporterCfg.showBrowser || false;
this.reportSlowerThan = config.reportSlowerThan || false;
};

Expand Down
15 changes: 15 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,21 @@ describe('SpecReporter', function() {
newSpecReporter.showSpecTiming.should.equal(true);
});
});

describe('and showBrowser is truthy', function () {
var newSpecReporter;
var config = {};
beforeEach(function () {
config.specReporter = {
showBrowser: true,
};
newSpecReporter = new SpecReporter[1](baseReporterDecorator, formatError, config);
});

it('should set the showBrowser flag to true', function () {
newSpecReporter.showBrowser.should.equal(true);
});
});
});
});

Expand Down

0 comments on commit b7a0051

Please sign in to comment.