jasmine-node icon indicating copy to clipboard operation
jasmine-node copied to clipboard

done is not defined

Open marktyers opened this issue 9 years ago • 3 comments

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.

marktyers avatar Mar 30 '15 14:03 marktyers

done() was not introduced to Jasmine until 2.1 I believe, but jasmine-node still uses the 1.3.1 version.

berkanyasul avatar Mar 30 '15 15:03 berkanyasul

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.

ingshtrom avatar Apr 13 '15 18:04 ingshtrom

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) {
                                     ^^^^

badcorporatelogo avatar Sep 18 '15 05:09 badcorporatelogo