iac-source-coupled-test
Disallow raw IaC source text as a test oracle; inspect a rendered plan, provider state, or runtime behavior.
Why
Substring and regex checks can pass on comments, formatting, or unreachable Terraform configuration while clients fail silently.
Fix
Reuse adequate existing validation; otherwise assert a distinct rendered-plan, provider-state, or runtime contract. Preserve deliberate representation contracts with an exact justified suppression.
Examples
import { readFileSync } from "node:fs";test("policy", () => { const source = readFileSync("main.tf", "utf8"); expect(source).toMatch(/prevent_destroy/);});import { readFileSync } from "node:fs";test("policy", () => { const plan = JSON.parse(readFileSync("plan.json", "utf8")); expect(validate(plan)).toEqual([]);});