NestJS With supertest 编译时不会显示“无法调用类型缺少调用签名的表达式”

Ste*_*idt 3 typescript nestjs

当尝试从 NestJS 示例运行 e2e 测试时,我的测试未编译为“无法调用其类型缺少调用签名的表达式”行

request(app.getHttpServer())
Run Code Online (Sandbox Code Playgroud)

代码来自 NestJS 测试示例。

这可能与我的 tsconfig 有关?

import * as request from "supertest";
import { Test } from "@nestjs/testing";
import { INestApplication } from "@nestjs/common";

describe("App", () => {
  let app: INestApplication;

  beforeAll(async () => {
    const module = await Test.createTestingModule({
      imports: []
    }).compile();

    app = module.createNestApplication();
    await app.init();
  });

  it(`/GET`, () => {
    return request(app.getHttpServer())
      .get("/")
      .expect(200);
  });

  afterAll(async () => {
    await app.close();
  });
});
Run Code Online (Sandbox Code Playgroud)

Ste*_*idt 8

这解决了它

import request from "supertest";
Run Code Online (Sandbox Code Playgroud)