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

refactor: update lib/reporter/multi.js to ES6 #3018

Merged
merged 1 commit into from
May 25, 2018
Merged

refactor: update lib/reporter/multi.js to ES6 #3018

merged 1 commit into from
May 25, 2018

Conversation

lusarz
Copy link
Contributor

@lusarz lusarz commented May 24, 2018

No description provided.

Copy link
Collaborator

@devoto13 devoto13 left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Contributor

@johnjbarton johnjbarton left a comment

Choose a reason for hiding this comment

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

Do we know what this code does? what happens if we add or remove an "adapter" from a reporter?

@lusarz
Copy link
Contributor Author

lusarz commented May 25, 2018

MultiReporter instance is returned from createReporters method:

return new MultiReporter(reporters)

so MultiReporter seems to be container that group a few reporters.

According to this implementation:

this.write = function () {
var msg = util.format.apply(null, Array.prototype.slice.call(arguments))
var self = this
this.adapters.forEach(function (adapter) {
if (!helper.isDefined(adapter.colors)) {
adapter.colors = useColors
}
if (!helper.isDefined(self.EXCLUSIVELY_USE_COLORS) || adapter.colors === self.EXCLUSIVELY_USE_COLORS) {
return adapter(msg)
}
})
}

adapter is function invoked with message inside reporter.write method. I guess adapter may allow to print to stdout, print to file etc.

@devoto13
Copy link
Collaborator

devoto13 commented May 25, 2018

@lusarz is right. adapters allow to configure where to send reporters' output (one or multiple destinations). It is used in one place - lib/middleware/runner.js. It basically adds response output stream as an adapter to all reporters (to send reporters output to the karma run script) and removes it after test run is complete.

@johnjbarton
Copy link
Contributor

Thanks! The change is simple enough but we don't have any tests and I did not see the code that uses this.

@johnjbarton johnjbarton merged commit c1526a1 into karma-runner:master May 25, 2018
@lusarz lusarz deleted the refactor-multi-reporter branch May 26, 2018 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants