-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
--format-options '{"colorsEnabled": false}' does not apply on error messages #1551
Comments
@hdorgeval I’m struggling to see how this relates to the html formatter - this is a console output issue? |
Hi @davidjgoss, the problem i described has almost no impact when the formatter outputs to the console. But it has a great impact when the preferred formatter is the html formatter as, in this case, error messages are unreadable. My point is that error messages are, at some point, handled by So my point is that in
export default function getColorFns(enabled: boolean): IColorFns {
if (enabled) {
return {
forStatus(status: messages.TestStepFinished.TestStepResult.Status) {
return {
[Status.AMBIGUOUS]: colors.red.bind(colors),
[Status.FAILED]: colors.red.bind(colors),
[Status.PASSED]: colors.green.bind(colors),
[Status.PENDING]: colors.yellow.bind(colors),
[Status.SKIPPED]: colors.cyan.bind(colors),
[Status.UNDEFINED]: colors.yellow.bind(colors),
[Status.UNKNOWN]: colors.yellow.bind(colors),
}[status]
},
location: colors.gray.bind(colors),
tag: colors.cyan.bind(colors),
}
} else {
// CONFIGURE CHALK BEHAVIOR FOR ALL MODULES THAT USES CHALK
process.env['FORCE_COLOR'] = '0';
return {
forStatus(status: messages.TestStepFinished.TestStepResult.Status) {
return _.identity
},
location: _.identity,
tag: _.identity,
}
}
} |
@davidjgoss , another way to solve this issue could be to say that the HTML formatter should support |
@hdorgeval okay I'm with you now. So as I see it we have a couple of issues:
I don't think we should be passing anything through chalk (or equiv) to emit messages, so we should stop that from happening as part of addressing the first issue. I think to display assertion errors nicely in the HTML formatter we should look to emit a more structured error object with I'll dig into this more a little later. |
@davidjgoss , for the first issue, this was a hidden issue in v6 because it was possible to set I definitely agree with you that emitted messages should not be generated with Thnks for your time 👍 For people reading this issue, the minimal workaround to correctly display error messages when using the HTML formatter is to set the environment variable |
@hdorgeval what assertion library are you using here? |
Related to this issue on `cucumber-js` here: cucumber/cucumber-js#1551, by default the HTML report will have color characters included which is very hard to read. Adding `FORCE_COLOR=0` env var is a workaround to fix it
Just to fill some of the blanks here, the assertion library in use is Jest's |
Closing after changes in 8.2.0, see https://github.com/cucumber/cucumber-js/blob/main/docs/formatters.md#colored-output |
Hello Cucumber Team,
Yet another issue related to displaying error messages with the internal HTML formatter:
Given I disable colors on the CLI with
--format-options '{"colorsEnabled": false}'
When a step fails
Then all logs are uncolored
But the Error message still uses
Chalk
red/green colorsExample in the console:
Example in the html report
And the corresponding envelope is:
In v6 the work around was to set
--no-color
( see chalk support color) on the CLI.Since it not possible any more in v7, the only way to fix this issue in v7 is to set the environment variable:
It would be great if you could either give back support for the
--no-color
option on the CLI or that you set theFORCE_COLOR
environment variable.In resume:
Given I disable colors on the CLI with
--format-options '{"colorsEnabled": false}'
And I set the environment variable
FORCE_COLOR
to 0When a step fails
Then all logs are uncolored
And the Error message is also uncolored
Example:
And the corresponding envelope is:
Thanks
The text was updated successfully, but these errors were encountered: