
The Edge Cases Your Tests Are Missing: A Pattern Library
You wrote tests. They pass. Coverage looks good. You ship to production and... it breaks. The problem isn't that you didn't write tests — it's that you tested the expected inputs while your users sent the unexpected ones. After cataloguing hundreds of production bugs, I've built a pattern library of edge cases that most test suites miss. Here's the collection, organized by type, with concrete examples you can apply today. The Null/Undefined/Empty Family This is the #1 source of production errors. For every function that accepts input, ask: "What if it's empty?" // Your function function getFullName ( user ) { return ` ${ user . firstName } ${ user . lastName } ` ; } // Tests you probably wrote test ( ' returns full name ' , () => { expect ( getFullName ({ firstName : ' Jane ' , lastName : ' Doe ' })) . toBe ( ' Jane Doe ' ); }); // Tests you probably DIDN'T write test ( ' handles null input ' , () => { expect (() => getFullName ( null )). toThrow (); }); test ( ' handles missing fields
Continue reading on Dev.to JavaScript
Opens in a new tab



