-
Notifications
You must be signed in to change notification settings - Fork 291
Asynchronous Tests
tebriel edited this page Feb 9, 2013
·
1 revision
jasmine-node includes an alternate syntax for writing asynchronous tests. Accepting a done callback in the specification will trigger jasmine-node to run the test asynchronously waiting until the done() callback is called.
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
});
An asynchronous test will fail after 5000 ms if done() is not called. This timeout can be changed by setting jasmine.DEFAULT_TIMEOUT_INTERVAL or by passing a timeout interval in the specification.
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
done();
}, 250); // timeout after 250 ms
});
Checkout spec/SampleSpecs.js to see how to use it.