Feature fix no colors to run command #1902
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have not identified and fixed the problem with the 3rd-party reporters not working. The problem was that the reporters didn't update the
USE_COLORS
property, from its default value:false
. The feature relies highly on this property to be updated and when it wasn't, the reporter would be interpreted as a no-color reporter.In-order not to break backwards compatibility, a new property was introduced:
EXCLUSIVELY_USE_COLORS
withundefined
as it's default value. By using this property, the no-colours feature (in the run command) will work for default reporters, i.e. dots and process, and reporters choosing to update the property.When fixing this, it became obvious why 3rd-party reporters didn't wan't to update this property: They didn't want to implement two reporters, because this would require for their users to add two reporters to their configuration.
For instance; for the mocha reporter, used in #1894, to implement this feature they would first implement two reporters, say
reporter:mocha
andreporter:mocha_color
, which would yield a configuration as:where omitting one would disable reporting w/w.o colours, depending on the omitted reporter.
I fixed this in 3294a15 by attempting (silently) to load a "coloured" version of a given reporter. Thus for the mocha reporter to support this feature, all they need to do is implement and export two reporters:
reporter:mocha
andreporter:mocha_color
. The user-configurations would remain unchanged: I.e.Given a reporter with name
foo
the coloured version must be namedfoo_color
, i.e. with postfix_color
.