typescript - 带有 supertest 的 NestJS 无法使用“无法调用类型缺少调用签名的表达式”进行编译
问题描述
当尝试从 NestJS 示例运行 e2e 测试时,我的测试没有编译为该行的“无法调用类型缺少调用签名的表达式”
request(app.getHttpServer())
代码来自 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();
});
});
解决方案
这修复了它
import request from "supertest";
推荐阅读
- ios - 只显示我的浮点数到某个小数位 - Swift
- python - 从另一个整数列表中按索引从列表中删除元素
- javascript - 量角器:自动 .sendKeys() 将我的文本转换为大写字母
- c# - 拖放事件后关联项目列表
- capl - 如何在 CAPL 的诊断请求中设置 DTC 状态位?
- python - 如何在 np.array 旁边保存整数
- scala-collections - 集合 Map 的不变性
- postgresql - pgp_sym_decrypt_bytea 没有返回预期值,我做错了什么?
- python - 如何确定一个列表是否包含另一个?
- google-sheets - 如何根据 Google 表格中的选项卡和单元格动态更改功能以进行下拉