mocha异步未定义

时间:2015-09-01 20:28:52

标签: node.js mocha

我正在使用mocha来测试用NodeJS编写的代码。

正在测试的代码,目标,使用异步。

function target(){
    ...
    async.waterfall([...]);
}

当我在

中通过它调用它时
it('should do something', function(){
    var result = target();  
    chai.expect(newAd0.coarseloc.longitude).to.be.within(-79.01,-78.99);
})
摩卡抱怨说

ReferenceError: async is not defined

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:2)

async是一个npm包,使用npm install async安装包。

在文件顶部添加:

var async = require('async');
相关问题