Skip to content

Commit cd639cc

Browse files
Merge pull request #5 from caplin/develop
Fix duplicated logs with multiple reporters
2 parents 1fda81f + 5674212 commit cd639cc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ module.exports = function(config) {
4646
reporters: [
4747
// other Karma Reporters
4848
'jasmine-order'
49-
]
49+
],
50+
disableJasmineOrderStandardLogging: true // Enable this when using with order loggers that log output to the console, to prevent duplicate loggin
5051
});
5152
};
5253
```

src/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
var createPattern = function (path) {
2-
return { pattern: path, included: true, served: true, watched: false };
2+
return {pattern: path, included: true, served: true, watched: false};
33
};
44

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

88
baseReporterDecorator(this);
99

10+
// Copied from "karma-jasmine-diff-reporter" source code:
11+
// In case, when multiple reporters are used in conjunction
12+
// with initSourcemapReporter, they both will show repetitive log
13+
// messages when displaying everything that supposed to write to terminal.
14+
// The config option allows for these repetitive logs to be suppressed
15+
// when using the reporter under these circumstances
16+
if(config.disableJasmineOrderStandardLogging) {
17+
this.writeCommonMsg = function () {
18+
};
19+
}
20+
1021
files.splice(
1122
files.length - 1,
1223
0,
@@ -21,7 +32,7 @@ var OrderReporter = function (config, baseReporterDecorator, emitter) {
2132
if (!data || data.type !== 'Jasmine Order Reporter') {
2233
return
2334
}
24-
reporter.onBrowserLog(browser, data.seedInfo, data.type);
35+
reporter.write(`\n${data.type.toUpperCase()}: ${data.seedInfo}\n`);
2536
});
2637
};
2738

0 commit comments

Comments
 (0)