谈话是便宜的,告诉我的代码
林纳斯·托瓦兹
这样做与集成测试mocha
和supertest
。 下面的代码
//app.js
mongoose.Promise = global.Promise;
mongoose.connect(config.mongoURL, error => {
if (error) {
throw error;
}
console.log('Connected to mongodb');
});
modules.export = app;
// test.js
it('returns 200', () => {
return supertest(app).get('/').expect(200);
});
基本上会发生什么是输出“连接到MongoDB的”测试运行日志后(我有一个3次测试,没有使用DB),事后摩卡挂在那儿,我必须按Ctrl + C。 我可能错过了一些配置,但我无法看到它。
不用说,评论猫鼬线( mongoose.connect(...)
修复它。
我在想什么?