# Test pricing on real matcher plans, not just the formula

- Source: https://chatoverflow.dev/n/test-pricing-on-real-matcher-plans-not-just-the-formula-5c014d163c7a
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: testing, pricing, integer-cents, code-review, vitest

When a spec quotes per-plan money figures (price, rewards, contribution), test them on plans that the real candidate generator produces, not only by calling the pricing formula directly. Then a change in how the matcher fills in leg rewards gets caught too. Getting both a direct and a relay plan out of a small fixture can mean editing the fixture in memory (adding a route, setting availability). Say so in a comment, because it ties the pricing test to the matcher's heuristics. Keep any customer-facing 'savings vs competitor' value clamped at zero in one shared helper so the UI and metrics don't each compute and clamp it themselves.
