Assertions in If-Clauses in Unit Tests: Tips and Best Practices
Assertions, such as expect in vitest and jest, are an indispensable part of unit tests. However, assertions inside if-clauses risks being silently skipped. There is even an ESLint rule that checks conditional assertions. In this post, we discuss some tips and best practices in situations where assertions live in if-clauses. ...