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

Fix duplicated logs with multiple reporters #5

Merged
merged 4 commits into from
Sep 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module.exports = function(config) {
reporters: [
// other Karma Reporters
'jasmine-order'
]
],
disableJasmineOrderStandardLogging: true // Enable this when using with order loggers that log output to the console, to prevent duplicate loggin
});
};
```
Expand Down
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
var createPattern = function (path) {
return { pattern: path, included: true, served: true, watched: false };
return {pattern: path, included: true, served: true, watched: false};
};

var OrderReporter = function (config, baseReporterDecorator, emitter) {
const files = config.files;

baseReporterDecorator(this);

// Copied from "karma-jasmine-diff-reporter" source code:
// In case, when multiple reporters are used in conjunction
// with initSourcemapReporter, they both will show repetitive log
// messages when displaying everything that supposed to write to terminal.
// The config option allows for these repetitive logs to be suppressed
// when using the reporter under these circumstances
if(config.disableJasmineOrderStandardLogging) {
this.writeCommonMsg = function () {
};
}

files.splice(
files.length - 1,
0,
Expand All @@ -21,7 +32,7 @@ var OrderReporter = function (config, baseReporterDecorator, emitter) {
if (!data || data.type !== 'Jasmine Order Reporter') {
return
}
reporter.onBrowserLog(browser, data.seedInfo, data.type);
reporter.write(`\n${data.type.toUpperCase()}: ${data.seedInfo}\n`);
});
};

Expand Down