Cypress CLI console output not very readable
Asked Answered
R

8

13

I'm running cypress tests headlessly and would like the console output to be a little more readable. Currently, I get a very messy output as seen below. According to the documentation it should be using the Mocha SPEC reporter layout. Can anyone tell me what I need to do to make this output readable?

I'm running ./node_modules/.bin/cypress run

Started video recording: ←[36mC:\code\website\ui\cypress\videos\vf7hm.mp4←[39m

←[90m  (←[4m←[1mTests Starting←[22m←[24m)←[39m

←[0m←[0m
←[0m  My First Test←[0m
  ←[32m  ΓêÜ←[0m←[90m Gets, types and asserts←[0m←[31m (18965ms)←[0m


←[92m ←[0m←[32m 1 passing←[0m←[90m (21s)←[0m


←[32m  (←[4m←[1mTests Finished←[22m←[24m)←[39m

←[37m  - Tests:           ←[39m←[32m1←[39m
←[37m  - Passes:          ←[39m←[32m1←[39m
←[37m  - Failures:        ←[39m←[32m0←[39m
←[37m  - Pending:         ←[39m←[32m0←[39m
←[37m  - Duration:        ←[39m←[32m20 seconds←[39m
←[37m  - Screenshots:     ←[39m←[32m0←[39m
←[37m  - Video Recorded:  ←[39m←[32mtrue←[39m
←[37m  - Cypress Version: ←[39m←[32m1.4.2←[39m


←[36m  (←[4m←[1mVideo←[22m←[24m)←[39m

  - Started processing:   ←[36mCompressing to 32 CRF←[39m
  - Finished processing:  ←[36mC:\code\website\ui\cypress\videos\vf7hm.mp4←[39m ←
[90m(1 second)←[39m


←[90m  (←[4m←[1mAll Done←[22m←[24m)←[39m
Retardant answered 6/2, 2018 at 2:51 Comment(5)
Those are font colouring sequences and control characters. Try turning off colour output?Coachandfour
I don't appear to have color output on. Although, now that you mention this, is it possible that the coloring from the reporter is just not supported on windows? I'm running this in a windows7 command prompt.Retardant
Yes, it is. That's why if you can turn it off at the app level, that could fix this.Coachandfour
I wonder if you couldn't grep out the command sequences. They're pretty distinctive. sed actually. Might be powershell could do it too.Howenstein
It seems they've made it much worse with a later version adding what I assume are supposed to be table borders: ┌───┠etc.Godliman
P
28

The messy output is because Cypress is using ANSI color escape characters to format the output, which your log viewer/console doesn't understand. You can disable the output of ANSI color control characters by setting the environment variable NO_COLOR:

NO_COLOR=1 cypress run

See https://docs.cypress.io/guides/continuous-integration/introduction#Colors

This was added in Cypress 3.0.0, released on 5/29/2018.

Papandreou answered 7/9, 2020 at 9:55 Comment(1)
Page not found for the first link!Microfiche
L
8

Could be two issues:


  1. Cypress is using ANSI colors, Jenkins isn't configured to convert this.

To fix: Install a plugin like this: https://plugins.jenkins.io/ansicolor/


  1. Encoding may not be UTF-8 (although it looks like yours is, others may not be)

To fix:

  • Navigate: Manage Jenkins => Configure System => Global Properties
  • Add env variable:
JAVA_TOOL_OPTIONS
-Dfile.encoding=UTF-8
Lecturer answered 15/5, 2020 at 1:51 Comment(1)
I got the ansicolor plugin. It seems to work for some things, but it isnt picking up cypress characters. Is there some special config I have to do for this?Polysyndeton
I
3

I was getting same issue and also I was not able to add ANSI colors plugin to my Jenkins so I just added NO_COLOR=1 before test case run command like follows:

NO_COLOR=1 npx cypress run

Adding this code to my command solved my issue which is a simple way and you don't even need to add any other plugin as well.

Ideologist answered 16/11, 2021 at 13:13 Comment(0)
O
1

From my knowledge, this is an issue specifically in Windows output in Cypress here: https://github.com/cypress-io/cypress/issues/1143

Overjoy answered 8/2, 2018 at 21:27 Comment(0)
P
1

This worked for me as well in jenkins CI

NO_COLOR=1 cypress run

Peaceable answered 5/10, 2022 at 19:33 Comment(0)
M
1

enter image description here - for bash:

export NO_COLOR=1 
cypress run
  • For Windows:
set NO_COLOR=1 
cypress run

worked for me

Massy answered 1/12, 2023 at 9:57 Comment(0)
L
0

As I am using Mac and setup jenkins locally on MAc so I was able to resolve this issue by using below command to execute script

NO_COLOR=1 cypress run

But my Server was on window and above NO_COLOR=1 solution didn't work for windows scenario So below are the steps through which I resolved this issue for windows

  1. Manage Jenkins > Plugins > Install AnsiColor plugin
  2. In Jenkins pipeline add below options code

options { ansiColor('xterm') }

need to add this AnsiColor option code after defining agent like this

pipeline{
agent any
options {         ansiColor('xterm')     }
tools {nodejs "node"}
  1. Now Restart your jenkins Server and execute the code

Above three steps worked for me.

Linguini answered 30/1, 2024 at 19:37 Comment(0)
D
0

If you are using a Docker file then add

ENV NO_COLOR=true

This command will resolve your problem.

enter image description here

that's it. :)

Devin answered 16/8, 2024 at 15:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.