const app = require('koa')();console.log(typeof app); // object
主要错误就是出现在项目实例是对象,在express下,就不错出现这种问题
const app = require('express')();const.log(typeof app); // function
完整代码:
// app.jsconst app = require('koa')(); app.listen(3000);module.exports = app;
// article.test.js const expect = require('chai').expect; const request = require('supertest'); const app = require('../app'); describe('api: /article', () => { describe('GET /article', (done) => { it('response is success', () => { request(app) .get('http://localhost/article') .expect(200) .end(() => { done(); }); // console.log(typeof app); }) }); });
哈士奇WWW
相关分类