Context
The test engine is the mock-test player for live exams on the learner platform. In 2026 I rebuilt it as a headless SDK and was its sole author. Schools use it for timed tests in many exam formats.
The problem
The legacy player was about 35k lines of code. Each exam format was a fork of the player, so changes were risky. Its behaviour was undocumented and it hid scoring bugs. Live exams cannot regress, and timers must be trusted from the server.
What I did
I reverse-specced the legacy code into a baseline spec and a parity matrix of 277 behaviours.
I built a headless SDK and consolidated 10 packages into 1, with layer rules enforced by a dependency check.
I implemented 15 question types, including a spreadsheet, a word processor, drag-and-drop and code questions.
I added server-anchored timers, autosave with recovery, an offline answer-sheet mode, and accessibility work to WCAG AA.
I wrote a production guard with a kill switch and percentage rollout, so the cutover could be reversed.
Key decision
I made exam families typed policy data instead of code forks. A preset describes an exam's rules, and an unknown exam type blocks rollout. I kept every URL the same.
The cost was a long reverse-engineering phase before shipping. It paid back: adding a format is now a data change, not a new copy of the player.
Result
The production mock-test route runs on the new SDK. Mutation score on repositories went from 39% to 78%. Reading the old code found real bugs: essays filed in the wrong field, multi-select partial credit divided by a hard-coded 4, and an analytics dedup bug.
Parity is not finished. As of 18 September, 55 of the 277 behaviours were still marked missing. I have no before-and-after completion or error rates.
What I learned
I would write the parity matrix again before any code. Next time I would involve a second reviewer earlier, since I was the only author.
Stack
- TypeScript
- React
- Vitest
- Playwright
- Stryker
- MathJax
