Skip to main content
Testing & QA Code Completion Medium +20 XP

Async Test

Complete the async test correctly.

Testing & QAFill in the blank
test('fetches user', ___ () => {
  const user = await getUser(1);
  expect(user.name).toBe('Alice');
});

Type the missing code

Show answer and explanation

Answer: async

To use await inside a Jest test, mark the callback as async. Jest awaits the returned promise automatically.

Hint: Which keyword enables await in the test function?

What this challenge tests

Code Completion in Testing & QA: jest, async.

Related challenges