jasmine-node done is not defined
Asked Answered
U

2

9

Have been trying a simple async test. Installed jasmine-node npm install -g jasmine-node then wrote a simple module and test.

Simple module.

// weather.js
exports.get = function(city, callback) {
    callback(city);
};

and a test suite.

// weather-spec.js
var list = require("../modules/weather");

describe("Weather Forecast", function(data) {
    it('should get weather for London,UK', function() {
        list.get('London,UK', function(data) {
            expect(data).toEqual('London,UK');
            done();
        });
    });
});

I get the error:

Stacktrace:
    ReferenceError: done is not defined

Given the simple example I can't see where I am going wrong. Can anyone help?

Unshod answered 30/3, 2015 at 14:30 Comment(0)
B
35

done is the first argument passed to it:

it('should get weather for London,UK', function(done) {
    list.get('London,UK', function(data) {
        expect(data).toEqual('London,UK');
        done();
    });
});
Brainchild answered 30/3, 2015 at 14:41 Comment(1)
Thank you. Can't believe I missed that!Unshod
A
1
describe("Weather Forecast", function(data) {
    it('should get weather for London,UK', function(done) {
        list.get('London,UK', function(data) {
            expect(data).toEqual('London,UK');
            done();
        });
    });
});

Make sure you pass in done in it's callback.

Advice answered 30/3, 2015 at 14:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.