Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress CLI console output not very readable

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
like image 858
Jmh2013 Avatar asked Feb 06 '18 02:02

Jmh2013


3 Answers

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.

like image 139
Michael Koch Avatar answered Oct 07 '22 07:10

Michael Koch


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
like image 7
Shain Lafazan Avatar answered Oct 07 '22 08:10

Shain Lafazan


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.

like image 3
sonali ugale Avatar answered Oct 07 '22 07:10

sonali ugale