ink-testing-library
ink-testing-library copied to clipboard
Create waitFor and renderHook utility functions
Hi, I ended up needing some utils to test my ink program properly, so I thought I might as well submit them here: waitFor
, and renderHook
. They're designed to resemble their React Testing Library counterparts.
I also added a test using them both, and added documentation to the readme.
Unfortunately, waitFor
won't work with ava assertions, because as far as I can tell, once an assertion fails, that's it for the test. And using this function, you just keep waiting in a loop and check every now and then if your assertion passes. It works with jest's expect
though, and it works if you simply pass an error-throwing function then use t.pass()
at the end of the test, so that's what I did.
I hope this will help others using this library. Let me know if I can improve anything.