简体   繁体   English

jasmine-node done未定义

[英]jasmine-node done is not defined

Have been trying a simple async test. 一直在尝试一个简单的异步测试。 Installed jasmine-node npm install -g jasmine-node then wrote a simple module and test. 安装jasmine-node npm install -g jasmine-node然后写了一个简单的模块并测试。

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? 有人可以帮忙吗?

done is the first argument passed to it : 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();
        });
    });
});

Make sure you pass in done in it 's callback. 确保在通过doneit的回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM