If you don’t have enough money, you’ll have to pay for it.

  node.js, question
const app = require('koa')();
 
 console.log(typeof app);  // object

The main error is that the project instance is an object, which is not bad under express.

const app = require('express')();
 
 const.log(typeof app);  // function

Complete code:

// app.js
 const 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);
 })
 });
 });

The answer has been found. There is a problem with the exported object. The return value of listen method should be exported.

// app.js
 module.exports = app.listen(3000);