home.test.ts 506 B

123456789101112131415161718192021
  1. import { createApp, close, createHttpRequest } from '@midwayjs/mock';
  2. import { Framework } from '@midwayjs/koa';
  3. describe('test/controller/home.test.ts', () => {
  4. it('should GET /', async () => {
  5. // create app
  6. const app = await createApp<Framework>();
  7. // make request
  8. const result = await createHttpRequest(app).get('/');
  9. // use expect by jest
  10. expect(result.status).toBe(200);
  11. expect(result.text).toBe('Hello Midwayjs!');
  12. // close app
  13. await close(app);
  14. });
  15. });