Assertions in Loops 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 loops risk being silently skipped. In this post, we discuss some tips and best practices to avoid situations where assertions live in loops. ...

 ·  · 2 min · 365 words

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. ...

 ·  · 3 min · 477 words