Improve the tests
As a matter of fact, the invalid data that we use isn't the primary issue in the test. The actual problem is that the verifications/assertions we add in the test are not evaluated by Jest in time. And hence the tests that we think have passed based on the result from Jest might actually have failed without us noticing. These tests become malfunctioning mini QA robots and will affect the health of our application. As you might have noticed, this kind of issue only happens when there is an asynchronous execution involved.
Another issue in our test is that we jumped to verify the redirection to the login page, which is one of the two possible final results of the submitForm() method, by skipping the verification of whether ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access