Closed billyvg closed 3 months ago
What you are looking for might be achievable by using the skipTest
option: https://github.com/ValentinH/jest-fail-on-console#skiptest
Afaict, there is no way currently to emit the warning, but not fail the test. If you would like to submit a PR, you'd want to take an option, and then use that to determine whether or not to throw here
This library could call the original console method, as following:
console[methodName] = (...args) => {
newMethod(...args);
originalMethod(...args);
}
That makes sense to me: the goal of this library is to fail the tests under some conditions, not to alter what is printed is the console.
I like this idea. We could add this behavior as a new option and make it the default. We would then release a new major version.
I would love this functionality as well.
My use case is that I have multiple tests where console.error
is called, but I cannot control when it gets called as the code being executed is outside of my control.
I'd really like to have the option to:
console[method]
call matches on certain textI can potentially submit a PR if you could point me in the right direction
I think that @clemp6r proposal is good. We could change the default behavior to let all logs go to the console and only make the test fail.
@ValentinH I've opened https://github.com/ValentinH/jest-fail-on-console/pull/48 and would appreciate any feedback you have
I would still like to see the
console.error
message when it happens, but be able to have the test not fail.