We have 159 passing tests around the module that turns a pound price into a local price. "Passing" tells you the tests agree with the code. It does not tell you they would notice if the code changed. So I changed the code on purpose, 35 times, and counted how often the suite complained.
This is mutation testing without a framework. No Stryker, no config. A 60-line Node script that swaps one expression in lib/pricing/display-currency.ts, runs the pricing and billing tests, records pass or fail, and puts the file back.
You can see the output of the module it attacks right now. Open pub-trivia.app/pricing. The page prices in the visitor's own currency, so from a UK address you see £30 and £100, and from a euro-area address you see €36.99 and €121.99. If you want to watch the code work, switch a VPN exit node to another country and reload.
The setup
The module does one job. Plans are stored as integer pence. For any other currency it multiplies by a fixed rate, adds a 4 per cent margin, and rounds up to the next retail figure (.99, or a whole unit for yen, forints and krónur). The page renders that number and Checkout charges exactly that number, so a wrong constant is a wrong charge, not a cosmetic bug.
That makes it a good place to ask whether the tests are doing anything. The suite is 43 tests in the module's own file plus the billing tests that call it, 159 in total, and it runs in about 200 milliseconds.
The script is short enough to describe in full:
for (const [name, from, to] of MUTANTS) { fs.writeFileSync(FILE, original.replace(from, to)) const run = spawnSync('pnpm', ['exec', 'vitest', 'run', 'pricing', 'billing']) record(name, run.status === 0 ? 'SURVIVED' : 'killed') } fs.writeFileSync(FILE, original) // in a finally block Every mutant is a plain string replacement, so each one is something a tired person could plausibly type: a flipped operator, a deleted guard, a changed constant, a swapped country.
One mutant needed a second attempt because my search string did not match the source. A mutant that silently does not apply looks exactly like a survivor, so the script reports "no match" separately. That is the first thing to build into one of these.
The result
35 mutants. 26 killed, 9 survived.
| Kind of change | Mutants | Killed |
|---|---|---|
| Arithmetic and rounding (margin, divide by 100, ceil to floor, step) | 9 | 9 |
| Which currencies have decimals (ISK, HUF, JPY lists, digit counts) | 8 | 8 |
| Formatting (fraction digits, whole-number check) | 3 | 3 |
| Input handling (trim, case, unknown country, bad numbers) | 7 | 5 |
| Table data (a rate, a country's currency) | 7 | 2 |
| Small print and the free-plan guard | 3 | 3 |
The pattern is clear before you read a single survivor. The tests are strong on behaviour and weak on data. Every change to a formula died. Most changes to a row in a table lived.
The nine survivors, sorted
Harmless, or at least not a bug I can show.
-
GBP rounds down: swappingMath.round(pence)forMath.floor(pence)for pounds. Plans are integer pence, so the two are the same function on every input the app can produce. An equivalent mutant. -
eur rate 1.1696 to 1.17: I nudged the euro rate up and the suite stayed green. The prices did not move either. £30 is €36.99 under both rates and £100 is €121.99, because rounding up to the next.99swallows a change that small. Fine, but it also means the suite cannot tell you when the rate is stale. It is not meant to. -
country lookup via plain index: the lookup goes throughhasOwnPropertyso that a country code ofconstructorcannot return a function. I replaced the guard with a plain index and nothing failed. The reason is that the code upper-cases the input first, andCONSTRUCTORis not a property of anything. The guard protects a case the earlier line already makes unreachable. I would still keep it, but its comment is describing a danger the code has already removed. -
epsilon removed: the1e-9that stops float error pushing an exact boundary up a whole unit. I could not build an input on our table that lands exactly on a boundary, so I cannot say whether this is equivalent or untested. I am reporting it as untested.
Real gaps.
-
parse trim removed:parseDisplayCurrency(" eur ")is meant to trim. No test passes whitespace. -
stripe fallback locale: for a currency outside our table, amounts are formatted withen-GB. Swapping it foren-USpasses. The fallback exists, and nothing pins what it says. -
LI moved to eurandXK removed: Liechtenstein belongs on the Swiss franc, Kosovo on the euro. The tests check the countries they happen to list, and these two are not among them. Move Liechtenstein to euros and every Liechtenstein visitor is quoted and charged a different currency, with a green build. -
ILS rate 4.0016 to 4.2: this is the one that matters.
The shekel one
The Israeli shekel rate is one of 24 in the table. I raised it by about 5 per cent. All 159 tests passed. The prices did not stay put:
| Plan | Rate 4.0016 | Rate 4.2 |
|---|---|---|
| £30 plan | ₪124.99 | ₪131.99 |
| £100 plan | ₪416.99 | ₪436.99 |
The £30 plan goes up by seven shekels and the £100 plan by twenty, and Checkout would charge it, because the page and the charge read the same function.
Why did nothing notice? The suite does pin prices, and the comment above that test says why: "Pinned so a rate-table edit, which now changes what customers pay, fails here rather than in front of a customer." But it pins five currencies: dollar, euro, krona, yen and forint. The other 19 are covered only by shape checks. Every rate is positive, the price clears the mid-market conversion plus margin, and it sits within one currency unit of it. A rate that is 5 per cent too high still clears the floor, and for a pound price of £30 the round-up allowance is wide enough to hide a shekel's worth of drift. The code comment says to refresh a rate "when it moves more than about 3%", which is a rule about deliberate edits. A deliberate edit and an accidental one look identical to the tests.
The fix is not clever, and the existing test already describes it. Extend the pinned list from five currencies to all 24, as literal strings in one table. That is 48 strings. Changing a rate then becomes a visible diff in a test file, which is what the comment asks for ("do it deliberately"). It would have killed the shekel mutant, and it would also kill any future one of the same kind. It would not catch Liechtenstein or Kosovo; those need a country table pinned the same way.
What I would copy from this
- Make the mutant list from your own mistakes, not from a tool's catalogue. Mine came from the module's own comments: the free-plan guard, the forint disagreement between engines, the Stripe zero-decimal list. Each of those was written because something once went wrong, and every one was caught, which is reassuring and slightly circular. The survivors came from the mutants I added after reading the table.
- Report "no match" separately. A mutation that did not apply is not a survivor.
- Expect the tests to be lopsided. Formulas get tests because they feel like logic. Tables get tests for their shape because their contents feel like data. Prices are data that move money.
- Do not fix survivors by adding assertions about the code. Fix them by adding assertions about the outcome. "ILS returns ₪124.99 for £30" is an outcome. "ILS rate equals 4.0016" is a copy of the source.
The script restored the file after every run and the working tree was clean at the end. If you want to see the number the tests are protecting, it is on the pricing page, and there is a free tier that needs no card if you would rather try the product itself.


