Javascript jasmine节点未定义
一直在尝试一个简单的异步测试。安装了jasmine节点Javascript jasmine节点未定义,javascript,node.js,jasmine-node,Javascript,Node.js,Jasmine Node,一直在尝试一个简单的异步测试。安装了jasmine节点npm安装-g jasmine节点,然后编写了一个简单的模块并进行了测试 简单模块 // weather.js exports.get = function(city, callback) { callback(city); }; 和一个测试套件 // weather-spec.js var list = require("../modules/weather"); describe("Weather Forecast", fun
npm安装-g jasmine节点,然后编写了一个简单的模块并进行了测试
简单模块
// weather.js
exports.get = function(city, callback) {
callback(city);
};
和一个测试套件
// 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();
});
});
确保在it的回调中传递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();
});
});
});