Playground
The same runner the JavaScript panels use, with the assertion helper already defined. A browser cannot run bash, Docker, kubectl or Terraform, so this is JavaScript only -- good for the arithmetic parts of the job: cost estimates, capacity planning, policy checks.
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const test = (name, got, want) => console.log(
(same(got, want) ? 'ok ' : 'FAIL ') + name +
(same(got, want) ? '' : ` got ${JSON.stringify(got)}, want ${JSON.stringify(want)}`)
);
// Never use === on a computed float. Money and percentages below are rounded first.
const close = (a, b, tol = 1e-9) => Math.abs(a - b) < tol;
// Try something. test(name, got, want) prints ok or FAIL.
const monthlyCost = (hourlyRate, hoursPerMonth) => hourlyRate * hoursPerMonth;
console.log('a t3.micro-ish rate for 730 hours =', monthlyCost(0.0104, 730));
test('a full month of a cheap instance is a few dollars', close(monthlyCost(0.0104, 730), 7.592), true);
Output