我有 koaapp
和 jest 测试框架,app
由 mongo 包装http.createServer
并连接到
mongooseConnect();
const app = new Koa();
initHandlers(app);
app.use(routes);
export default http.createServer(app.callback());
测试超测后不要关闭服务器,测试示例
test('success create user', (done) => {
return supertest(app)
.post(`/api/auth/signup`)
.send(userData)
.expect(200)
.expect({
data: {
email: userData.email,
firstName: userData.firstName.toLowerCase(),
lastName: userData.lastName.toLowerCase(),
bio: userData.bio,
},
}, done);
});