q-supertest
q-supertest
supercharges SuperTest with a then
method, that returns Q promise.
Instead of layering callbacks on callbacks in your tests:
;
chain your requests like you were promised:
return ;
Usage
q-supertest
operates just like normal SuperTest, except that the
object returned by .get
, .post
, etc. is a proper
thenable:
var express = request = ; var app = ; ;
If you use a promise-friendly test runner, you can just
return your request
chain from the test case rather than messing with a
callback:
;
Agents
If you use a SuperTest agent to persist cookies, those are thenable too:
var agent = ; agent
Promisey goodness
To start, only the then
method is exposed. But once you've called .then
once, you've got a proper Q promise that supports the whole gamut of
promisey goodness:
// I'm a real promise now!
See the Q API for everything that's available.
Installation
Node
$ npm install q-supertest
q-supertest
lists supertest
as a
peer dependency, so it'll wrap whatever version of SuperTest
you've asked for in your own package.json
. If you don't specify a version of
SuperTest, npm will use the latest.
Do note that q-supertest
is a well-behaved citizen and doesn't monkey-patch
SuperTest directly:
// I return thenables!var request = ; // I'm lame and force you to use callbacksvar request = ;