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

formatter: colorsEnabled: true not honoured #2011

Closed
davidjgoss opened this issue Apr 27, 2022 · 5 comments Β· Fixed by #2026
Closed

formatter: colorsEnabled: true not honoured #2011

davidjgoss opened this issue Apr 27, 2022 · 5 comments Β· Fixed by #2026
Assignees
Labels
πŸ› bug Defect / Bug

Comments

@davidjgoss
Copy link
Contributor

davidjgoss commented Apr 27, 2022

πŸ‘“ What did you see?

When outputting to a non-TTY environment, using colorsEnabled: true in the format options doesn't result in colours being output.

βœ… What did you expect to see?

Colours to be output, because of this logic:

if (doesNotHaveValue(configuration.options.colorsEnabled)) {
      typeOptions.parsedArgvOptions.colorsEnabled = (
        stream as TtyWriteStream
      ).isTTY
    }

In other words, if we specify the option, it should output colours without checking if the stream is TTY.

πŸ“¦ Which tool/library version are you using?

cucumber-js 8.1.2

πŸ”¬ How could we reproduce it?

TBA

@davidjgoss davidjgoss added the πŸ› bug Defect / Bug label Apr 27, 2022
@davidjgoss
Copy link
Contributor Author

davidjgoss commented Apr 27, 2022

@binarymist I've raised this as the place to discuss your issue from #1711 (comment).

Am I right that you're running cucumber-js on a server environment and then presenting the output to users elsewhere? So you add colorsEnabled: true to explicitly enable coloured output.

For 8.0.0 we switched libraries from colors to chalk for well-known reasons, but I notice that chalk does auto detection of colours support and noops if it doesn't find it https://github.com/chalk/chalk#supportscolor so we may need to make some changes in our integration there to force it to honour our option. In the meantime if it's possible, could you try setting FORCE_COLOR=1 as an env variable where you run cucumber-js?

cc @aurelien-reeves

@binarymist
Copy link

binarymist commented Apr 27, 2022

Hi @davidjgoss and thanks!

Am I right that you're running cucumber-js on a server environment and then presenting the output to users elsewhere? So you add colorsEnabled: true to explicitly enable coloured output.

Yes. the CLI text output with colour codes is sent to Redis which lands in the orchestrator service. The orchestrator then sends the text from Redis to the CLI which is on the end users machine.

Also note we're still on "@cucumber/cucumber": "^8.0.0-rc.3" @aurelien-reeves

Will try FORCE_COLOR=1 when we get a chance.


I think that's from running the Cli programmatically where you provide argv as string[]

Correct.

The creation of the cucumber args

Where the cucumber args are used

@aurelien-reeves

First of all, that option is true per default, so you should be able to not specifying that option.

The option has been there for 3-4 years. Not sure it's always been default?

Also, why that coma between format-options and the options? And the quotes?

Because it's an array (see above link to "The creation of the cucumber args"). Nothing has changed here in over 3 years.

Thanks both.

@mpkorstanje mpkorstanje pinned this issue Apr 27, 2022
@davidjgoss davidjgoss self-assigned this May 1, 2022
@binarymist
Copy link

binarymist commented May 4, 2022

FORCE_COLOR=1 does enable colours. What's your strategy from here @davidjgoss... I guess to retain the origonal behaviour without setting an environment variable? Ideally we'd like any configuration to be as close as possible and obvious to the running of cucumber.

@aurelien-reeves
Copy link
Contributor

You can look at #2026 to see what is going on

@davidjgoss
Copy link
Contributor Author

This is released in 8.2.0, see the updated doc: https://github.com/cucumber/cucumber-js/blob/main/docs/formatters.md#colored-output

@davidjgoss davidjgoss unpinned this issue May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
πŸ› bug Defect / Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants