I'm using shelljs and jest to test a shell script. The shell script will fallback to an interactive mode if it doesn't find certain variables it's looking for, and for most of the tests, the variables should be set and so that shouldn't happen.
So, what I want is to fail the test if the process tries to read from stdin
. I have an intuition I can do this by mocking stdin
, but glancing at the Node process
API I didn't see an event corresponding to 'waiting on input' or anything so I'm turning to the community.
E.g., if the shell script has something like:
if [[ -z "$FOO" ]]; then
read -p "FOO: " FOO # <- I want to trigger failure in the jest test
fi