I am trying to test my HTTP endpoint. The endpoint function takes (req, res) and, after number of internal async operations, should invoke res.json when done.
For some reasons my test app does not wait for the resolution and finishes the execution:
function testPromise() {
return Q.Promise(function (resolve, reject, notify) {
console.log('run query ...');
req = { query: { ... }};
res = { json: resolve };
controller.runQueryHTTP(req, res, undefined);
return Q();
}).then(function (output) {
console.log('after run query ...');
should(output).have.property('err', null);
should(output).have.property('res');
console.log("test passed");
return true;
});
}
Q(testPromise()).then(function () {
console.log("Testing complete.");
}).catch(function (err) {
throw err;
}).done();
Here is my console output:
Polinas-MacBook:me3 polina$ node spike
run query ...
Polinas-MacBook:me3 polina$
What am i doing wrong?
Aucun commentaire:
Enregistrer un commentaire