Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Mocking behavior based on TTY shell #40

Open
riggtravis opened this issue May 15, 2020 · 1 comment
Open

Mocking behavior based on TTY shell #40

riggtravis opened this issue May 15, 2020 · 1 comment

Comments

@riggtravis
Copy link

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.

@riggtravis
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant