Node.js 如何使用mocha和requestify测试外部HTTP资源

Node.js 如何使用mocha和requestify测试外部HTTP资源,node.js,mocha.js,requestify,Node.js,Mocha.js,Requestify,我正在尝试使用mocha对外部HTTP资源进行一个简单的测试。这是我的密码: describe('bing.com', function() { it('should return 200 for a GET request', function() { var requestify = require('requestify'); requestify.get('http://bing.com') .then(function(

我正在尝试使用mocha对外部HTTP资源进行一个简单的测试。这是我的密码:

describe('bing.com', function() {
    it('should return 200 for a GET request', function() {
        var requestify = require('requestify');

        requestify.get('http://bing.com')
            .then(function(response) {
                // Get the response body (JSON parsed or jQuery object for XMLs)
                console.log(response.getBody());
                done();
            });
    });
});

测试只是说通过了,但从未显示我的
console.log
调用。mocha是否在收到http响应之前完成

您没有向测试函数提供
done
回调:


描述('bing.com',函数(){
它('GET请求应返回200',函数(完成){
...

要捕获这样的错误,您应该使用JSHint(或Jslint)检查代码。这两种方法都会通知您,done()调用将无法工作,因为未定义变量