Eric
Eric

Reputation: 96

How to disable colors in Jest output

When I run Jest in a terminal with a light background, its yellow output is totally unreadable.

I have tried to find any options that allow me to customize the colors, or turn off output coloring altogether. I found plenty of suggestions with --colors to turn output colors on but that is the opposite of what I need.

I am using Linux with an xterm window, with black text on a white background.

Upvotes: 7

Views: 3266

Answers (3)

surj
surj

Reputation: 4913

Using FORCE_COLOR=false environment variable worked for me.

See: https://jestjs.io/docs/cli#--colors

Upvotes: 1

Terry Tú Nguyễn
Terry Tú Nguyễn

Reputation: 380

For jest==29.7.0, none of the common solutions works for me (FORCE_COLOR=false, --no-colors, --colors=false, --color=false) I had to work around:

npm test | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" &> logs.txt

I hope this helps someone

Upvotes: 0

Lin Du
Lin Du

Reputation: 102587

For version "jest": "^24.8.0", use jest --no-colors command to disable the colors of test output.

Upvotes: 11

Related Questions