Banjer
Banjer

Reputation: 8320

Disable color output in react-scripts test

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

Answers (2)

Емил Цоков
Емил Цоков

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

Russell Standish
Russell Standish

Reputation: 49

"env FORCE_COLOR=0" worked for me.

Neither "npm config set color false" nor "npm --no-color" worked, though.

Upvotes: 2

Related Questions