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
Parse rendered plan JSON, query the provider, or exercise the deployed runtime contract.
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([]);});