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

Added options object to be able to overwrite logging #36

Merged
merged 3 commits into from Feb 3, 2020
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
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear this will be copy/pasted even for people not using karma-mocha-reporter. Can you add a 2nd example specifically for karma-mocha-reporter to avoid this? Also, your reporters list doesn't actually list karma-mocha-reporter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are correct, will do.

}

});
};
```

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