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 risk being silently skipped. There is even an ESLint rule no-conditional-expect that checks conditional assertions. In this post, we discuss some tips and best practices to avoid situations where assertions live in if-clauses. ...