colors: true
doesn't work when provided in jest.config.js
.
I use Git Bash on Windows. Jest doesn't color output in my terminal.
I use colors: true
in jest.config.js
. And it doesn't work.
Colors only works when provided as a command line option
$ npm test -- --colors
Why is it so? I don't want to type anything more than necessary. I want to type npm test
and it should work. How to enable this behavior?
BTW, colors: true
in package.json
doesn't work either.
Unknown option "debug" with value true was found. This is probably a typing mistake. Fixing it will remove this message.
Why so many configs? You have at least three now that do nor work coordinated. How can I use just one simple config file within which I can declare everything needed? I want to declare any configuration just in jest.config.js
. No command line options, no package.json
options. All in jest.config.js
. How can I do it?
And I'm curious.
Why have you made up three different config places with three different sets of config options? Do you provide three different products or just one?
That's because --colors
is kinda special option, which processed by chalk
. Read more about it here: https://github.com/chalk/chalk#chalksupportscolor.
Other than that you should be able to set up all config options through a config file (you can use either jest.config.js
or jest
key in package.json
, but not both). If not, please file a proper issue.
I had the same frustration, this solution worked for me:
Add it to your package.json scripts -> test.
"scripts": {
"test": "jest --colors"
},
Hope that helps.
Add export FORCE_COLOR=true
into your .bash_profile
or .bashrc
.
@remsikr marvelous!
Forcing color option this way seems hacky, don't you think?
(but it works great anyway!)
"scripts": { "test": "FORCE_COLOR=true jest" }
seems the simplest way to go.
If you are using docker-compose the soluction provede by @remsikr works!
@yamsellem's solution fixed my issues with Docker-Compose not showing color output.
Most helpful comment
Add
export FORCE_COLOR=true
into your.bash_profile
or.bashrc
.