Finding bugs before users do is what separates senior from junior developers. Here's my checklist of edge cases to always test.
Input Edge Cases
// Empty/null/undefined
handleInput("");
handleInput(null);
handleInput(undefined);
// Boundary values
handleAge(0);
handleAge(-1);
handleAge(150);
handleAge(Number.MAX_SAFE_INTEGER);
// Special strings
handleName("O'Brien"); // Apostrophe
handleName("José García"); // Unicode
handleName(" "); // Whitespace only
handleName("<script>alert(1)</script>"); // XSS attempt
handleName("a".repeat(10000)); // Very long inputArray Edge Cases
// Empty array
sortItems([]);
filterItems([]);
getFirst([]);
// Single element
sortItems([1]);
// Duplicates
sortItems([3, 1, 3, 2, 1]);
// Already sorted
sortItems([1, 2, 3, 4, 5]);
// Reverse sorted
sortItems([5, 4, 3, 2, 1]);
// Large arrays
sortItems(Array.from({ length: 100000 }, () => Math.random()));Async Edge Cases
// Race conditions
// What if user clicks "Submit" twice?
// What if search results arrive out of order?
// What if component unmounts during fetch?
// Network failures
// What if the API is down?
// What if the request times out?
// What if we get a 500 error?
// What if we get a 429 (rate limited)?
// Stale data
// What if cached data is outdated?
// What if another tab modified the data?UI Edge Cases
// Responsive design
// Very narrow viewport (320px)
// Very wide viewport (4K)
// Landscape mobile
// Content overflow
// Very long text without spaces
// Very long URLs
// Missing images (broken img src)
// Interaction
// Double-click on submit button
// Press Enter in form fields
// Tab navigation order
// Screen reader navigationDate/Time Edge Cases
// Time zones
new Date("2024-01-01") // UTC midnight — different date in some time zones!
// DST transitions
// March 10, 2024 2:00 AM doesn't exist (spring forward)
// November 3, 2024 1:00 AM happens twice (fall back)
// Leap year
new Date(2024, 1, 29) // Valid (2024 is leap year)
new Date(2023, 1, 29) // Becomes March 1, 2023!
// Edge dates
new Date("0000-01-01")
new Date("9999-12-31")The Testing Mindset
- Always test the happy path AND the sad path
- Think: "What if the user does something unexpected?"
- Think: "What if the server returns something unexpected?"
- Test with realistic data volumes, not just toy examples
- Test on slow networks (Chrome DevTools → Network throttling)