茉莉花节点完成没有定义

一直在尝试一个简单的asynchronoustesting。 安装jasmine-node npm install -g jasmine-node然后写了一个简单的模块并testing。

简单的模块。

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

和一个testing套件。

 // 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(); }); }); }); 

我得到的错误:

 Stacktrace: ReferenceError: done is not defined 

鉴于这个简单的例子,我不明白我要去哪里错了。 谁能帮忙?

done是传递给it的第一个参数:

 it('should get weather for London,UK', function(done) { list.get('London,UK', function(data) { expect(data).toEqual('London,UK'); done(); }); }); 
 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(); }); }); }); 

确保你的callback完成。