How to assert with promises? #3235
-
Hello, all! I would like to assert on the promise of a boolean, or, in other words, to assert on an async function returning a boolean. This, for the purpose of testing async code. This is how I am tying it, currently: This mostly works, but leaves out the important aspect of a failed expectation within the assert callback, which would cause minimization. What happens now is that expect fails, but after assert is already done, which gives me a warning, but no indication of which input caused it. This is an example of that: When naively trying to assert with an async callback, I get a typescript compiler error saying that this is not possible. How may I assert with promises? Many thanks to the contributors for this great package! Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi ! |
Beta Was this translation helpful? Give feedback.
Hi !
If you want to test asynchronous functions, look at
fc.asyncProperty
instead offc.property
.For reference: https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/documentation/Runners.md#properties