-
I have async tests I'm testing complex async code (programming language) and I'm just working on try..catch I've added code that throws an error inside the Promise constructor that is caught. THe code works fine when I try to replicate the same code from unit tests in NodeJS but Ava keeps showing me an error:
I was reading the code and it seems that ava uses There are no unhandled rejections in my code. To explain my use case. I had a programming language (Scheme) and I've had a problem with
The problem was the So I need to disable this flaky unhandled promise rejection. Even if this is for a single test. There should be a way to have some hooks inside the library to change it. Unfortunately, I can't use any other library since this is the only one that is async and works with my code. EDIT: I was trying to reproduce the issue with a smaller code, but I was not able to do this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I was able to fix the issue by ignoring the exception I used to escape from try..catch: process.on('unhandledRejection', (reason, promise) => {
if (reason instanceof IgnoreException) {
promise.catch(noop);
}
}); The same function can be used to ignore any unhandled rejection reported by AVA. |
Beta Was this translation helpful? Give feedback.
-
I believe In other words: it should only highlight rejected promises that are unhandled when AVA has completed the test execution. I do think that is legitimate. |
Beta Was this translation helpful? Give feedback.
I was able to fix the issue by ignoring the exception I used to escape from try..catch:
The same function can be used to ignore any unhandled rejection reported by AVA.