Reputation: 8320
Is there a way to disable colorized output for tests run via react-scripts test
? I'd like to disable this to get rid of the color control codes in our CI pipeline.
With jest you can specify jest --no-colors
, but react-scripts test --no-colors
does not seem to pass the option down to jest.
FYI, the app was created with create-react-app
and the react version is 17.0.0.
Upvotes: 2
Views: 1083
Reputation: 692
Neither of the proposed solutions worked for me. ("react-scripts": "5.0.0")
My solution for this was installing as dev dep "@relmify/jest-serializer-strip-ansi" and in package.json have this
"jest": {
"snapshotSerializers": [
"@relmify/jest-serializer-strip-ansi/always"
]
},
List of supported jest config overwrites for CRA https://create-react-app.dev/docs/running-tests/#configuration
Upvotes: 0
Reputation: 49
"env FORCE_COLOR=0" worked for me.
Neither "npm config set color false" nor "npm --no-color" worked, though.
Upvotes: 2