You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
testing: validate both JSON and HCL synth output in core unit tests, not just JSON snapshots #563
Most unit tests in packages/cdktn/test snapshot JSON synth output. Nothing checks that the output is valid Terraform, and the HCL path is rarely checked at all. Several recent bugs were visible in snapshots or only affected HCL, and none failed a test:
Add a shared helper that synthesizes a stack in both modes and runs toBeValidTerraform on each, then use it in the suites that cover core blocks (variables, outputs, locals, backends, lifecycle, moved/import/removed).
A provider-free stack validates in about 0.5s with no network: init -backend=false plus validate. I tried this on a variable stack with Terraform 1.14.3 and OpenTofu 1.12.6. CI already runs the unit tests against Terraform 1.5.7, 1.16.1 and OpenTofu 1.12.6.
On a machine without the binary, the helper could fall back to snapshot-only, the same way other tests auto-skip.
Activity