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

explict calls to `fail-on-console` without register #46

Open piranna opened 6 months ago

piranna commented 6 months ago

I try as most as possible to not use console or any other UI function inside my code, so it can easily be reusable as libraries. I use instead error events a lot, or if not possible provide callbacks for errors management, so I define them only in the actual tests files just by providing console.error function object as the callback / event listener. At the same time, I use console methods during debugging and later remove them, so what I want is a function that get the error message and throw it also on async events and functions. Maybe a simplified version of patchConsoleMethod() without the actual patching would do the job, so it would just be a matter of split the code.

ValentinH commented 6 months ago

I'm not sure I fully get the use case but I'm okay to review a PR if it's about refactoring a bit to export an interval function.