Here's an example of how I test the results of a POST to my API:
api.post(test, path1, req1, resc1, function(res1) {
test.ok(res1.hasOwnProperty('foo'), 'Expected foo property.');
test.ok(res1.foo == true);
test.ok(res1.hasOwnProperty('bar'), 'Expected bar property.');
test.ok(res1.bar == 3);
test.done();
});
The problem I am facing is that -- if the response does not have the property 'foo' -- while the first line of the test might fail, the next line also gets tested, and I get an error instead of test results.
(Yes, I could nest the tests within if/thens that retest what was just tested, but that seems a pretty gruesome workaround.)
Aucun commentaire:
Enregistrer un commentaire