Clarify "thenable" #330

Closed
cowwoc opened this Issue Dec 24, 2012 · 6 comments

Projects

None yet

3 participants

@cowwoc
cowwoc commented Dec 24, 2012

The documentation says that asynchronous tests can return a "thenable" but does not provide a code sample. It's not clear how this would work. Please provide some sample code as part of the documentation.

@briancavalier

@cjohansen can correct me if I'm wrong, but in this case, a "thenable" means any Promises/A+ compliant promise, such as those of when.js, Q, etc., or a "promise-like" object with a then method that is close enough in behavior to Promises/A+, such as jQuery Deferred.

Buster will detect that a test has returned a promise, and will only consider the test to be done when the promise fulfills or rejects, which (I think) will signify the outcome of the test (pass/fail).

Buster uses when.js internally, so it can handle most anything that resembles a thenable promise. As shown here, you can roll your own simple "promise-like" object for very simple cases. Or you can use a full promise implementation to create a promise and return it.

Hope that helps!

@cowwoc
cowwoc commented Jan 4, 2013

I would recommend linking the word "thenable" to the last link you included.

@briancavalier

@cowwoc Good call

@cjohansen
Member

Sounds good. @cowwoc where did you find the unlinked "thenable" reference?

@cowwoc
cowwoc commented Jan 4, 2013

Go to http://docs.busterjs.org/en/latest/overview/ and search for "thenable".

@cjohansen
Member

Done!

@cjohansen cjohansen closed this Jan 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment