My white-label voice AI portal, VoiceDash, creates Stripe subscriptions, reports metered usage, and charges agencies' clients real money. It has 133 commits on main, 205 TypeScript files, and zero test files. The only script in package.json besides dev and build is lint. There is no test runner installed.
I am not proud of that, but I am also not going to pretend it is unusual for a solo-built product. What I want to share is what happened when I sat down with a guide we wrote at my studio about testing, took its main rule seriously, and pointed it at my own code.
The rule is simple: test where mistakes are expensive, not evenly. The guide lists four areas that almost always deserve heavy testing: money, permissions, integrations, and data changes. So instead of "add tests to VoiceDash", which is a project I would never start, I asked a smaller question: which functions in those four areas could I test today, with no database and no mocks, in under an hour?
Then I actually ran them. Here is what I found.
Money: the functions are pure, which is the good news
VoiceDash keeps its money helpers in src/lib/billing/money.ts. They convert between what an agency types into a form and what Stripe wants:
/** "49.00" in USD → 4900 cents. */ export function toMinor(amount: number, currency: string): number { return Math.round(amount * minorUnitFactor(currency)); } export function toMinorDecimal(amount: number, currency: string, divideBy = 1): string { const value = (amount * minorUnitFactor(currency)) / divideBy; return Number(value.toFixed(12)).toString(); } minorUnitFactor returns 1 for Stripe's zero-decimal currencies (JPY, KRW and friends) and 100 for everything else. toMinorDecimal exists for per-minute pricing billed per second: $0.15 per minute becomes a per-second unit price of "0.25" cents.
I copied these into a scratch file and ran a table of inputs through them. The comment's own example holds: toMinorDecimal(0.15, "usd", 60) returns "0.25". toMinor(19.99, "usd") is 1999, and toMinor(49, "jpy") is 49, not 4900. Good.
The interesting case is a price that does not divide evenly. $0.10 per minute becomes "0.166666666667" cents per second, which is fine for Stripe since unit_amount_decimal accepts 12 decimal places. But the UI formats unit prices with at most four fraction digits, so the agency sees $0.0017 per second. That is a correct rounding of the display, and the stored price is still exact. Nothing is wrong. But this is exactly the kind of thing where, six months from now, someone (me) changes the formatter to "fix" a display complaint and quietly changes what gets sent to Stripe. A ten-line table test pins the contract: these inputs, these strings, forever.
None of this needs a database. It is the cheapest test in the codebase and it guards the most expensive mistake.
Usage billing: the test I would have written found a real gap
VoiceDash supports three usage metrics for client subscriptions: per minute, per call, and "value based", where a call is only billable if a field from Retell's post-call analysis came back true. For example, an agency can bill only for calls where appointment_booked was true. The decision lives in one pure function:
case "VALUE_BASED": { const data = (call.metadata as any)?.call_analysis?.custom_analysis_data; if (!data || !sub.valueField) return null; const v = data[sub.valueField]; return v === true || v === "true" || v === "yes" ? 1 : null; } Writing the test table was the first time I listed the inputs explicitly instead of imagining them. The results:
| value in the analysis | billed? |
|---|---|
true | yes |
"true" | yes |
"yes" | yes |
"Yes" | no |
"TRUE" | no |
1 | no |
"1" | no |
If an agency set up its analysis field as a boolean, this works. If they set it up as text or a choice field and the model writes "Yes" with a capital Y, every one of those calls is silently not billed. No error, no log line. The null just means "skip this call", which is the same thing it means for a call that legitimately was not a booking.
I have not seen this happen in production, and I am not going to claim it has. But the point of the exercise is that I found it in about four minutes by writing the test table, and I would never have found it by reading the code, because I wrote the code and I read it the way I meant it. The fix is to normalize the value (trim, lowercase, accept 1) and to log when a value-based field exists but is not a recognized boolean. Neither is shipped yet.
Dashboards and invoices should not disagree
The analytics route totals call minutes like this:
for (const c of conversations) totalMinutes += Math.round((c.duration || 0) / 60); It rounds each call to whole minutes, then sums. Usage billing, meanwhile, sends Stripe the call length in seconds. Four 29-second calls show up on the dashboard as 0 minutes and on the per-minute invoice as 116 seconds. A client who compares the two will think one of them is wrong, and they would be half right.
This is not a money bug, since the invoice is the accurate side. But it is a trust bug in a product whose whole pitch is "your clients see a clean dashboard". The fix is to sum seconds first and round once. The test is three lines.
Regression tests for bugs I already fixed
The testing guide has a rule I like a lot: every serious bug that gets fixed should get a test, so it cannot come back quietly.
In September I added getSubscriptionPeriodEnd, because newer Stripe API versions moved current_period_end from the subscription object onto its items, and without a fallback the app could write an Invalid Date into a non-nullable column. The function checks the subscription, then the first item, then trial_end, then projects 30 or 365 days from now. It has a good comment explaining all of that. It has no test. If someone simplifies it back to sub.current_period_end, the comment goes with it and the bug returns on the next Stripe upgrade.
That is the cheapest kind of regression test there is: three fake subscription objects, one for each shape Stripe has actually sent, and an assertion that the result is a valid date.
Integrations: the one test that needs a database
The fifth test is the one I care about most and the one that costs the most to write. reportForSubscription reports finished calls to Stripe as meter events, and its comment promises it is "safe to run any number of times". The design is sound: it writes a billingUsageReport row keyed on subscription and call before calling Stripe, treats a unique-constraint failure as "a concurrent run already did this", and deletes the row if the Stripe call fails so the next run retries. I wrote about why billing paths like this deserve care in Five Code Paths Write the Same Subscription Row.
But "safe to run any number of times" is a claim, and right now the only evidence for it is my memory of an 87-item hand test plan I ran in a Stripe sandbox. A real test would run the function twice against a throwaway Postgres with a fake Stripe client that fails once, and assert two things: each call is reported exactly once across both runs, and the failed one is retried. That needs a test database and a seam for the Stripe client, so it is a half day, not an hour. It is still the right half day to spend.
The order I'm adding them in
-
money.tstable test (no dependencies, 15 minutes) -
usageValuetable test, plus the normalization fix it exposed -
getSubscriptionPeriodEndregression test with three Stripe payload shapes - Analytics: sum seconds, round once, three-line test
-
reportForSubscriptionidempotency test against a real database
Permissions tests (agency vs client sessions, inactive clients locked out) come right after, and they also need the database, so they share the setup from step 5.
The runner will be Vitest in a Node environment, wired into a GitHub Actions job on every pull request. As I admitted in my zero-reviews post, the only gate my code has today is next build failing on a type error. Types would not have caught a single thing on this list.
What I took from it
Two things. First, "we should add tests" never happens, but "these five functions, in this order" can happen this week. Ranking by cost of a mistake turned an endless chore into a short list.
Second, I used to think of writing tests as checking code I already trusted. Writing the input table for usageValue was the opposite: it was the first time I had to state, explicitly, what the function should do with "Yes". That question had simply never come up. AI coding tools make drafting these tests fast now, but deciding which rows go in the table is still the actual work.
The original version of this, written for people hiring a development team rather than for developers, is on our studio site: Software Testing and QA: What to Expect From Your Development Team.
If you run a solo or tiny-team product that handles money: what was the first test you wrote, and did it find something?
