

My Tests Fail If Anyone Types a Dollar Amount by Hand
About this episode
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.
Comments
Rate this episode
Episode Details
- Author
- HackerNoon
- Show Type
- full
- Audio Format
- audio/mpeg