-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reporters should be immune to interference with STDOUT #3604
Comments
If possible, ensure this is enforced by ESLint, as we do with the timers. |
Or more simply, provide the ability to redirect to file. |
I think you’re conflating two separate issues. Even if any reporter could write to a built-in or user-defined stream, that stream would need to be protected from test harness interference. |
I like the idea of base utility/s to unify reporters and make them more resilient. Happy to have a go when I get time. |
@boneskull with so many of our reporter tests relying on interfering with Worth noting |
Can you show how it'd be necessary to change them? I think we can just change the helper function
Not sure I understand. |
I think it'd be helpful to see a proof of concept. |
I'll put something together |
Closing as PR was merged. |
Potentially related: #2943
If a reporter uses
console.log()
, it should retain the function like we do with timers.This will theoretically allow users to stub out
console.log()
in their own tests without affecting reporter output.Since
console.log()
expectsthis
to beconsole
, it likely needs to take a form of:process.stdout.write()
may need to be consumed in a similar manner.To reproduce the problem:
Another approach would be to instantiate our own
Console
object (docs) which would bypass the globalconsole
entirely. We could consider subclassingConsole
in order to provide a nice abstraction for reporters consumingprocess.stdout
directly (or other streams).A workaround (for the user) would be to use something like proxyquire, rewiremock, etc. in lieu of replacing the method outright, like one would with Sinon.
The text was updated successfully, but these errors were encountered: