我正在尝试在我的 locomotive.js 应用程序上编写测试,从互联网上的一些示例中复制/粘贴代码。即便如此,每当我运行测试时,我都会收到一条错误消息
TypeError: string is not a function
当我检查 locomotive.boot 预期的参数数量(使用 locomotive.boot.length)时,它显示 2 ......但在每个在线示例中(继续,谷歌它)文档似乎都说 3。有谁知道我做错了什么?
这是我的代码:
var locomotive = require('locomotive'),
should = require('should'),
request = require('supertest');
var app, server;
describe('Application', function() {
before(function(done) {
locomotive.boot( __dirname+"/..", "test", function(err, express) {
if (err) throw err;
app = this;
express.listen(4000, '0.0.0.0', function() {
var addr = this.address();
console.log('Server started. [Env: '+SOPS.conf.get('app:environment')+'] [Addr: '+addr.address+'] [Port: '+addr.port+']');
done();
});
server = express;
});
});
it('should have started the app', function(){
should.exist(app);
should.exist(express);
});
});