My Tests Fail If Anyone Types a Dollar Amount by Hand
This story was originally published on HackerNoon at: https://hackernoon.com/my-tests-fail-if-anyone-types-a-dollar-amount-by-hand.
A one-line Vitest rule bans hand-typed prices in MDX; components and build-time SVG charts pull every number from one function.
Check more stories related to programming at: https://hackernoon.com/c/programming. You can also check exclusive content about #programming, #javascript, #web-development, #testing, #astro, #data-visualization, #svg, #static-site-generator, and more.
This story was written by: @horushe93. Learn more about this writer by checking @horushe93's about page, and for more stories, please visit hackernoon.com.
I run a concrete cost calculator whose data refreshes monthly, so any price typed into an article goes stale. My rule: no dollar sign followed by a digit anywhere in prose. A Vitest test enforces it, MDX components put computed numbers inside sentences, and one pure function feeds the table, a zero-JS SVG chart and its alt text. Tests also pin the direction of each claim the prose makes.
You May Also Like

Jak Piggott
Jak Piggott

Elon Musk Podcast
Stage Zero

The Times Tech Podcast
The Sunday Times
.jpg)
Programmieren lernen - Der Developer Akademie Podcast
[email protected] (Developer Akademie)

TyfloPodcast
TyfloPodcast
The Deep Dive Radio Show and Nick's Nerd News
Nick Espinosa, Chief Security Fanatic

ITSPmagazine
ITSPmagazine, Sean Martin, Marco Ciappelli

Artificial Intelligence Masterclass
AI Masterclass

Daily Tech News Show
Tom Merritt

The Linux Cast
The Linux Cast
Community discussion