Fill: async/await Test
Fill in the Blank Medium
Question
Fill in the blank to make this an async test:
Code
test('async test', ___ () => {
const result = await fetchData();
expect(result).toBe('data');
});
Hint
The keyword for declaring an async function.
Explanation
The correct answer is async. By marking the test callback as async, you can use await inside it. Jest will wait for the async operations to complete before finishing the test and evaluating the assertions.
Related Resources
Related Lessons
- Async Testing
Testing asynchronous code.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.