Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add showBrowser config option to print browser for each spec #80

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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.
},
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,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 @@ -144,7 +145,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 @@ -196,6 +197,7 @@ var SpecReporter = function (baseReporterDecorator, formatError, config) {
this.specFailure = reporterCfg.suppressFailed ? noop : this.onSpecFailure;
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 @@ -265,6 +265,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