cypress: Don't output colors or fancy characters when run from continuous integration
Current behavior:
FYI, I’m using the Module API. If I missed an option somewhere, please let me know.
Here’s a sample of the output from my Jenkins job log:
┌────────────────────────────────────────────────────────────────────────────────────────────────�
│ Cypress: 3.1.4 │
│ Browser: Electron 59 (headless) │
│ Specs: 1 found (config\clipboard.spec.ts) │
│ Searched: cypress\integration\config\clipboard.spec.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: config\clipboard.spec.ts... (1 of 1)
(Results)
┌────────────────────────────────────────�
│ Tests: 4 │
│ Passing: 0 │
│ Failing: 0 │
│ Pending: 4 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 0 seconds │
│ Spec Ran: config\clipboard.spec.ts │
└────────────────────────────────────────┘
Desired behavior:
No color escape sequences or non-ASCII characters when running from CI (Jenkins in my case).
Versions
Cypress 3.1.4
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 17 (2 by maintainers)
There is support for this, but seems undocumented: Set
NO_COLOR=1env var.See https://github.com/cypress-io/cypress/issues/1748#issuecomment-390682159
It isn’t perfect, but it suppresses most of the things I’m seeing. I’ll open a ticket for the things it doesn’t suppress.
My Jenkins console output looks like this for cypress tests:
I don’t understand why there is no option to disable color in output. This seems like a basic requirement for any type of testing – the results should be easy to view and quickly assess. This jumble of formatting is anything but. Also the
cypress runoutput TRUNCATES the test file names, which makes it very difficult to locate the spec files that resulted in errors.I know this is closed but as a reference: NO_COLOR works BUT it still keeps the ASCII Art (the boxes) which trip up eg. jenkins.
This is done inside the cypress “binary” / package and is a
cli-table3under the hood which currently has no switch to turn it of.Since we have a fixed package cache path on our ci (
npm install --cache /tmp/cachedir) we can “fix” this via asedcommand:Yep. I still think it’s good to have an “ASCII-mode” flag in cypress (or any tooling that is used from CI) but this issue is definitely lower priority now for me.
This NO_COLOR=1 has not worked on any cypress run command I’ve tried. They all end up with color in them. So I can’t even figure out how to set it up properly for my CI environment because in my testing IT ALWAYS FAILS.
To add to this, it messed up the newer versions of GitLab CI logs too. Looks like GitLab adds a new line for every colour code making our test logs hundreds of screens tall.
In case this helps any Windows users… I fixed this issue when running Cypress through PowerShell by prepending the following to my command:
So now my command looks like this:
Using the NO_COLOR environment variable didn’t affect the output for me, but adding the line above fixed it.
Would love to see a
--no-coloroption. Most of the text in the console output is black and doesn’t show very well in gitlab ci.Also for local dev I prefer to have plain b&w for simplicity and uniformity.