Do you want to request a _feature_ or report a _bug_?
This is a feature request
What is the current behavior?
Currently jest prints the console.log() messages to the console
What is the expected behavior?
This feature would allow providing a custom logger via a CLI flag and the all the console.log() message would be given to the custom logger so it can decide what to do with it.
This would allow tools that are built on top of jest to handle the console logs the way they want.
You can do this using a setupFile, is that not sufficient?
If I understand correctly, setupFiles should be configured in the config and cannot be passed as CLI args which means the config has to be modified by the tool. Also came across https://github.com/facebook/jest/issues/1022 but not sure how this was handled.
setupFiles can be specified through the CLI.
Great. I'll give it a try. @SimenB proposed this idea but i'm not sure what he had in mind.
My thought was to pass in a custom TestConsole implementation which could do whatever.
So the first condition could be globalConfig.console or something.
But if just overwriting console.{warn,log,info,error} in a setup file covers your use case, I suppose that's good enough?
For my use-case, overriding in a setup file is good enough. Thank you, all! Closing this for now.
Setup file overwriting breaks the --silent option. Passing a custom console through the config as @SimenB proposes is a good idea.
Most helpful comment
For my use-case, overriding in a setup file is good enough. Thank you, all! Closing this for now.