ValentinH / jest-fail-on-console

Utility to make jest tests fail when console.error() or any other methods are used
MIT License
141 stars 20 forks source link

Incompatible with `chalk@5` #43

Closed kopach closed 7 months ago

kopach commented 7 months ago

I have chalk@5 in my project. When I run tests with jest-fail-on-console enabled — I'm getting errors like TypeError: chalk.red is not a function

There is also an issue with package.json of jest-fail-on-console. It doesn't specify chalk in peerDependency section, therefore required for project chalk version is neither validated during install nor installed.


update

Just found docs on chalk v5 breaking changes https://github.com/chalk/chalk/releases/tag/v5.0.0 and there are stated

It's totally fine to stay on Chalk v4. It's been stable for years.

So, just update to package.json of jest-fail-on-console to include chalk@4 in peerDependency would be enough

kopach commented 7 months ago

sorry, my mistake, I had chalk mocked under __mocks__ folder which caused all the issues for me, anyway still doesn't work with chalk@5

ValentinH commented 7 months ago

chalk V4 is declared as a dependency so it should be installed regardless of the version you are using.

kopach commented 7 months ago

I see. Btw, how about to get rid of chalk as a dependency at all? There is no much usage of it, special characters to color output can be hard coded. The problem with chalk (apart of forcing users to install it) is that it's widely used and in some cases we actually want to mock it in tests (as I mentioned above) as it's external dependency. But if we mock it - jest-fail-on-console would also stop working :( What do you think @ValentinH ? Let me know if you need help with this

ValentinH commented 7 months ago

I get the point. I have zero knowledge on this topic but I would be happy to review a PR removing chalk and hardcoding the tokens.

Would it work on windows as well?