Skip to content

Commit

Permalink
Added options object to be able to overwrite logging (#36)
Browse files Browse the repository at this point in the history
* feat(config): disable specFailure logging

* docs(readme): added config to readme

* docs: separate config with options
  • Loading branch information
PVermeer committed Feb 3, 2020
1 parent 5c422fa commit c0b3176
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -28,6 +28,26 @@ module.exports = function(config) {
});
};
```
#### With options
In combination with multiple reporters you may want to disable failed messages because it's already handled by another reporter.

*Example when using the 'karma-mocha-reporter' plugin*:
```js
// karma.conf.js
module.exports = function(config) {
config.set({

// Combine multiple reporters
reporters: ['kjhtml', 'mocha'],

jasmineHtmlReporter: {
// Suppress failed messages
suppressFailed: true
}

});
};
```

You can pass a list of reporters as a CLI argument too:
```bash
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Expand Up @@ -3,11 +3,20 @@ var createPattern = function (path) {
return { pattern: path, included: true, served: true, watched: false };
};

var initReporter = function (files, baseReporterDecorator) {
var initReporter = function (karmaConfig, baseReporterDecorator) {
var jasmineCoreIndex = 0;

const files = karmaConfig.files;

baseReporterDecorator(this);

if (karmaConfig.jasmineHtmlReporter) {
const config = karmaConfig.jasmineHtmlReporter;
if (config.suppressFailed) {
this.specFailure = () => void 0;
}
}

files.forEach(function (file, index) {
if (JASMINE_CORE_PATTERN.test(file.pattern)) {
jasmineCoreIndex = index;
Expand All @@ -19,7 +28,7 @@ var initReporter = function (files, baseReporterDecorator) {
files.splice(++jasmineCoreIndex, 0, createPattern(__dirname + '/lib/adapter.js'));
};

initReporter.$inject = ['config.files', 'baseReporterDecorator'];
initReporter.$inject = ['config', 'baseReporterDecorator'];

module.exports = {
'reporter:kjhtml': ['type', initReporter]
Expand Down

0 comments on commit c0b3176

Please sign in to comment.