【发布时间】:2023-01-20 16:51:43
【问题描述】:
我想将现有的 terraform 模块集成到 cdktf 中。使用 cdktf get 创建一个 typescript TerraformModule。我可以在单元测试 (jtest) 中引用和评估它吗?
import { MyLocalModule1 } from "../.gen/modules/my-local-module1";
describe("My CDKTF Application", () => {
describe("Unit testing using assertions", () => {
it("should contain a resource", () => {
expect(
Testing.synthScope((scope) => {
new MyStack(scope, "my-app");
})
).toHaveResource(MyLocalModule1)
expect(Testing.fullSynth(stack)).toBeValidTerraform()
});
});
上面的代码不起作用,因为类型“typeof MyLocalModule1”不可分配给类型“TerraformConstructor”的参数。类型“typeof MyLocalModule1”中缺少属性“tfResourceType”,但类型“TerraformConstructor”中需要属性“tfResourceType”。
cdktf get
npm run test
【问题讨论】: