Reputation: 1750
I want to test some promises with jasmine node. However, the test runs but it says that there are 0 assertions. This is my code, is there something wrong? The then part is successfully called, so if I have a console.log there, it gets called. If I have the code test a http request, on the success, the assertion is correctly interpretated.
describe('Unit tests', function () {
it("contains spec with an expectation", function() {
service.getAllClients().then(function (res) {
expect("hello world").toEqual("hello world");
done();
}).catch(function (err) {
fail();
});
});
});
Upvotes: 0
Views: 743
Reputation: 350272
You need to specify the done
argument to the callback you pass to it
, so Jasmine knows you are testing something asynchronously:
it("contains spec with an expectation", function(done) {
// ...
When you include that parameter, Jasmine will wait for a while for you to call done
so it knows when you're done.
done();
Secondly, in an asynchronous test, it probably is better to fail with a call of done.fail
:
done.fail();
Upvotes: 3