A test suite for CommonJS Promises/A and related spec extensions
The tests run in Node.js.
You create an adapter in
lib/adapters, reading the
README.md file there for guidance. Then you change the
lib/promises-a.js to point to your adapter. Then you run
So far we have adapters for jQuery (fails), promise-stream (fails), Q (passes), and when.js (passes).
You can get the related libraries by running
npm install, but you'll still have to manually switch the
to that adapter. (By default it runs the tests against Q.)
There is, unfortunately, a very common and important behavior of thenables that is actually not in the Promises/A spec: what happens when one of your handlers returns a promise? For concreteness, let's use this example:
var a = bthenreturn c; // `c` is a promise;
Most implementations have converged on the answer that
a should be resolved in the same way as
ashould be fulfilled if and only if
cis fulfilled, and with
c's fulfillment value
ashould be rejected if and only if
cis rejected, and with
c's rejection reason
Unfortunately the Promises/A spec alone seems to imply that
a should always be fulfilled, with the promise
c as its
Tests for this are included in
lib/common-extensions.js and can be run with
npm run test-extensions, using the
same adapter framework as above. Currently jQuery, Q, and when.js pass, while promise-stream fails.
I'd also like something less silly than requiring you to go in manually and change the adapter
require line. Maybe
a prompt, or maybe just loop through and run them all?
Finally, it'd be cool to expand these tests to cover the behavior of deferreds, which are more or less the canonical promise-creation technique. There are a few subtleties there regarding resolving a deferred with a pending promise that not everyone gets right. That's beyond the scope of Promises/A, but there's a reason I named the repo "promise-tests" instead of "promises-a-tests" :).