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.
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 insteaderror
events a lot, or if not possible provide callbacks for errors management, so I define them only in the actual tests files just by providingconsole.error
function object as the callback / event listener. At the same time, I useconsole
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 ofpatchConsoleMethod()
without the actual patching would do the job, so it would just be a matter of split the code.