oberstet
oberstet

Reputation: 22051

JS test framework that works with Deferreds/Promises

I am looking for a JavaScript test framework that natively works with Deferreds/Promises.

That is: my test case functions will return a Deferred (e.g. jQuery Deferred or whenjs) that when fires will yield true or false (success/failure).

A framework that only provides mechanisms to test specific async stuff like AJAX is not sufficient.

Upvotes: 1

Views: 146

Answers (1)

Stuart K
Stuart K

Reputation: 3282

Jasmine can be easily patched to allow promises to be returned from it blocks. This is how we do it Montage: https://github.com/montagejs/montage/blob/master/test/support/spec-helper.js#L96-120. The spec is failed if the promise is rejected or is fulfilled with a value (not undefined). You can adapt it as needed.

Buster, another test framework, natively supports specs returning promises.

Upvotes: 2

Related Questions