How to assert for an asynchronous exception in Expecto without RunSynchronously?

Viewed 51

I have started to use F# Expecto framework and cannot find a proper way to assert for an exception in async computation expressions.

My code ended up with:

Expect.throws (fun () ->
    async {
        // Some async code expected to fail...
        do! Async.Sleep 1
        failwith "error"
    }
    |> Async.RunSynchronously
    |> ignore) "valuable message"

Is there a better way to do this? (without RunSynchronously and ignore).

Thanks

0 Answers
Related