Start a project

252 golden cases: testing a calculator a client depends on

MidTeQ's energy check sizes a solar, battery and heat pump system for a homeowner and sends the result to their sales team as a lead. The formula came from the client. Our job was to put it in the browser in seven languages without changing what it says.

Freeze the answers first

Before touching the code we recorded 252 input combinations and the results the client's own engine gave for them. Those files are the specification. Any change that moves one number fails the build.

src/calculation/golden.test.ts
import cases from "./__fixtures__/golden.json";
import { calculate } from "./engine";

describe("matches the client's engine", () => {
  it.each(cases)("$name", ({ input, expected }) => {
    expect(calculate(input)).toEqual(expected);
  });
});

Version the formula

Every lead carries the formula version that priced it. When MidTeQ confirmed new battery values (90% depth of discharge, 92% round-trip efficiency), the version changed and the old leads still say what they were promised.

Then test the real page

Unit tests prove the maths. Playwright proves the product: it builds the site and drives the real form in Chromium for every country and language pair, so a translated label or a postcode check cannot quietly break one market.

Planning web apps?

Email what it should do, who will use it and when you need it. The people who would build it reply.