Skip to content

单元测试

Zongmin Lei edited this page Aug 21, 2018 · 2 revisions

使用 supertest 或 superagent

通过 app.server 获取原始的 http.Server 实例,无需 listen() 监听端口:

import { Application } from "@leizm/web";
import * as request from "supertest";

describe("单元测试", function () {
  it("使用app.server", async function () {
    const app = new Application();
    await request(app.server).get("/").expect(200);
  });
});
Clone this wiki locally