Skip Navigation
8hob.io Assertions in If-Clauses in Unit Tests: Tips and Best Practices

In unit tests, assertions inside if-clauses risks being silently skipped. We discuss some tips and best practices in situations where assertions live in if-clauses.

Generally, it is inadvisable to directly expect in if-clauses. Here are some tips to avoid these situations.

2
Jump
draw.io no longer open source since August 27, 2024
  • Yes, I agree. Too many people are overly obsessed with the exact definition of "Open Source". But come on, this now "proprietary" software is only tiny bit different from an open source software and shares almost no similarity with a typical proprietary software.

    And more importantly, this new license is even arguably better than an open core model.

    2
  • Jump
    A Type-Safer Alternative to Type Guards in TypeScript
  • Using a third-party library when it's applicable definitely works. Much of this post is for those who can't add a heavy dependency :)

    3
  • 8hob.io A Type-Safer Alternative to Type Guards in TypeScript

    Type guards rely on the programmer to be correctly defined and are error-prone. We introduce the type extractor, which may be a safer alternative in many scenarios.

    A trick that I'd like sharing :)

    2