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

refactor: ➖ remove `chalk` as dependency #44

Closed kopach closed 7 months ago

kopach commented 7 months ago

fixes: #43

Some docs: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences

Tested on Linux & Mac Haven't tested on Windows

Simple test

image

kopach commented 7 months ago

@ValentinH , please review

Some tests are failing, but could be an issue with tests, not sure. Please, check and feel free to update this PR as you need

ValentinH commented 7 months ago

The tests are pretty trustworthy. It seems that only the cases that check the actual behavior of tests failed by failOnConsole are failing. Maybe the original chalk has a different behavior when used in tests/Jest?

kopach commented 7 months ago

as those test cases meant to fail, I guess, toThrow https://jestjs.io/docs/expect#tothrowerror should be used instead. what do you think?

ValentinH commented 7 months ago

Unfortunately this isn't that easy. These tests are actually using Jest to test a Jest plugin. That's why we are using this "fixture" pattern.

ValentinH commented 7 months ago

Unfortunately this isn't that easy. These tests are actually using Jest to test a Jest plugin. That's why we are using this "fixture" pattern.

kopach commented 7 months ago

ok, found issue, will try to debug

ValentinH commented 7 months ago

Thanks for this contribution. It was released as https://github.com/ValentinH/jest-fail-on-console/releases/tag/v3.1.2