Spectre icon indicating copy to clipboard operation
Spectre copied to clipboard

Testing async methods

Open onevcat opened this issue 8 years ago • 2 comments

Hi, @kylef

I want to test some async methods. Is it now supported in Spectre?

I just had a brief look at Spectre but didn't find this feature. Maybe something like this in other BDD testing framework:

$0.it("should do something asynchronously") {
    waitUntil { done in
        //.. async work
        done()
    }
}

If this is not yet in Spectre, I'd like to try to implement (although I have no experience on creating a test framework). Before I could get into it, I think it's better to confirm it. What do you think about it?

onevcat avatar Mar 08 '17 01:03 onevcat

This will depend on how the work is ran, i.e, if you are using Cocoa, libuv, or lib dispatch etc. You will need to write some "wait" function which will block until the event happens in your specific run loop.

kylef avatar Sep 27 '17 19:09 kylef

Adding to this, it would be neat to make an extension for it which accepts returning a promise/signal or similiar to wait for. Shouldn't be too hard to integrate into any particular event loop used.

kylef avatar Aug 21 '18 14:08 kylef