【发布时间】:2022-09-28 16:06:14
【问题描述】:
我在 monorepo 中有一个 nestjs 后端 api 服务器。我想使用 supertest 进行集成测试。我目前在 package.json 中针对jest --env=node --verbose 命令配置了 e2e。
例如,检查 http://localhost:8112/health 是否返回 OK。
it(\'should pass\', async () => {
const res = await request(http://localhost:8112/health)
.get(\'/health\')
.expect(200);
expect(res.text).toEqual(\'OK\');
});
我希望 api url 端点是动态的。如果它的暂存 stg-xyz.com/health 或 prod prod-xyz.com。 我如何达到同样的效果?
-
选项 1. 环境变量 选项 2. 从某种配置中心服务获取 API 端点
标签: jestjs nestjs e2e-testing ts-jest supertest