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 2 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
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -24,7 +24,14 @@ npm install karma-jasmine-html-reporter --save-dev
// karma.conf.js
module.exports = function(config) {
config.set({
reporters: ['kjhtml']

reporters: ['kjhtml'],

jasmineHtmlReporter: {
// Suppress failed messages (e.g. in combination with karma-mocha-reporter)
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.

}

});
};
```
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