Avoid using toBeTruthy() and toBeFalsy() matchers

Test assertions should be explicit. If I’m trying to assert that something should be true I avoid using the toBeTruthy() matcher. It’s important to realize that in JavaScript, all values are truthy unless they are defined as falsy. This means that as long as result is not a falsy value (e.g. false, "", null, undefined, NaN, etc.), the assertion will pass. expect(result).toBeTruthy() // passes if result is {} or [] or 1 Contrast it with this approach where result will only pass if its value is true....

1 min · Jesstern Rays

Run Jest tests that match a describe block

How to run tests that only match the name in the describe block

1 min · Jesstern Rays

Watch for file changes as you run your tests

How to run your tests as your files change in Jest

1 min · Jesstern Rays