Jasmine-node done undefined

Tried a simple asynchronous test. Installed jasmine is 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 set of tests.

 // 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 an error message:

 Stacktrace: ReferenceError: done is not defined 

Given a simple example, I do not see where I am wrong. Can anyone help?

+6
source share
2 answers

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(); }); }); 
+24
source
 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 go through done in it callback.

+1
source

Source: https://habr.com/ru/post/984443/


All Articles