Mocking behavior based on TTY shell
riggtravis opened this issue · comments
I have branching logic based on whether or not stdout is TTY or not. I've been looking around for any information about how to do this. I'm probably going to end up doing this in stdout-stderr by explicitly setting the isTTY
property of process.stdout
to undefined. However, this feels... gross. If I could I'd like to be able to do this in a clean fashion in facy-test.
As an update I had briefly found a way to use the stub method to set the property of process.stdout.isTTY to undefined. However, while I was trying to sort out why my istanbul test coverage was misaligned, I broke this as the third argument of the .stub()
method is supposed to be of type () => any
. I'm rather frustrated by this problem as process.stdouout.isTTY is of type undefined | boolean
so mocking it in a way that doesn't return NaN when I'm attempting to base logic on whether code is currently running in a TTY terminal or not is seemingly impossible