Skip to main content
Testing & QA Bug Hunt Easy +10 XP

Missing Async Await

This test always passes even when the promise rejects.

Testing & QAFind the bug
1test("fetches user", () => {
2 expect(fetchUser(1)).resolves.toBe("Alice");
3});
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: Add async/await or return the promise

Without returning or awaiting, Jest doesn't wait for the assertion. Always return or await promises in tests.

Hint: Jest must know to wait for the assertion.

What this challenge tests

Bug Hunt in Testing & QA: jest, async-testing.

Related challenges