Testing · Junior · Question 75 of 78
Why doesn't this test catch a bug?
test("saves", () => {
save(data).then((result) => {
expect(result.ok).toBe(true);
});
});- ✓Correct answer: The promise isn't returned or awaited, so the test finishes before the assertion
- 2
thendoesn't work in tests - 3
toBecan't compare booleans
Explanation
Add return or make the test async and await the promise.