charmbracelet / vhs

Your CLI home video recorder 📼
MIT License
14.7k stars 247 forks source link

Testing for expected stdout/stderr/tty and exit status #358

Open balupton opened 1 year ago

balupton commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to use VHS to test my CLI applications to ensure the output and exit status is as expected. Currently this does not seem supported.

Describe the solution you'd like

Set Shell bash
Output confirm.gif
Type "confirm --positive --ppid=$$ -- 'testing ctrl+c'"
Sleep 1s
Enter
Sleep 1s
Ctrl+C
Sleep 1s
Expect ExitStatus Failure # aka != 0
Expect TTY "testing ctrl+c ABORT
Terminated: 15"

Describe alternatives you've considered So far I've been using https://github.com/bevry/dorothy/blob/master/commands/eval-tester for this, which is working well enough. However I was hoping I could use VHS also for testing failure conditions.

Additional context Can't reproduce as any vhs playback is failing for me: https://github.com/charmbracelet/vhs/issues/350

femtotrader commented 7 months ago

This feature will be great to have. I'm showing usage of a Julia library and I have to fine tune Sleep value to allow sufficient time to dependencies to be downloaded before sending Type commands. Having an "Expect" like feature could greatly help !