Skip to content

Commit

Permalink
Merge pull request #5 from caplin/develop
Browse files Browse the repository at this point in the history
Fix duplicated logs with multiple reporters
  • Loading branch information
dmitryshindin authored Sep 11, 2024
2 parents 1fda81f + 5674212 commit cd639cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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

0 comments on commit cd639cc

Please sign in to comment.