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

Fail tests on console assertion failure #15

Closed doug-wade closed 2 years ago

doug-wade commented 2 years ago

Currently, you can error when one of three console methods are called: log, warn, and error. For libraries that are using console.assert to do validation (such as I'm using for parameter validation in this project ), a failed console assertion is an indication of a problem of some kind. Here, I add a new method stub to console to intercept calls to assert, and fail the test only if the assertion fails. This is behind a parameter which defaults to false, so upgrading clients shouldn't be disrupted, and we shouldn't have to bump the major version.

ValentinH commented 2 years ago

Thanks for this contribution and sorry for the delay 🙈 ! This was published as v2.3.0 🎉