jasmine-node
jasmine-node copied to clipboard
done is not defined
Writing a trivial module and async test but getting an error 'done is not defined'.
// weather.js
exports.get = function(city, callback) {
callback(city);
};
// weather-spec.js
var list = require("../modules/weather");
describe("Weather Forecast", function () {
it('should get weather for London,UK', function() {
list.get('London,UK', function(data) {
expect(data).toEqual('London,UK');
done();
});
});
});
All the module does is spit out the parameter as a parameter to the callback.
done() was not introduced to Jasmine until 2.1 I believe, but jasmine-node still uses the 1.3.1 version.
generally, done is passed as a parameter to the it()
callback. I am having the same problem though, even though the docs say that done() is supported.
You need to declare a parameter done
(or whatever else you might want to call it) in your it
test function before you use it. This parameter declaration is what tells jasmine-node that you're invoking an async test rather than a synchronous test.
it('does something async', function (done) {
^^^^