How do I use AVA to test a library that registers an unhandledRejection callback:
process.on('unhandledRejection', e =>
// do something effectful
);
In this environment, unhandled rejections are not necessarily errors in the library. I want to ensure that my library is robust against users' callbacks causing an unhandled rejection.
Without a way to do this, I have to use a different testing framework (like Tape) to execute those tests.
AVA will consider unhandled rejections in test files to be a failure. You'd have to run your code "elsewhere", being a child process or worker thread.
I want to ensure that my library is robust against users' callbacks causing an unhandled rejection.
IMHO that's your users problem. If your library calls user provided code and you're awaiting a promise return value you could try / catch that error, but arguably letting the program crash is perfectly valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With