[英]jasmine-node done is not defined
一直在尝试一个简单的异步测试。 安装jasmine-node npm install -g jasmine-node
然后写了一个简单的模块并测试。
简单的模块。
// 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();
});
});
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();
});
});
});
确保在通过done
在it
的回调。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.