Next.js · Middle · Question 70 of 75
What is the recommended way to test an async server component?
- ✓Correct answer: End-to-end tests (e.g. Playwright), since unit tools don't fully support async server components yet
- 2Render it with
@testing-library/reactlike any component - 3Snapshot its JSX with Jest
Explanation
Synchronous server and client components can be unit-tested with Vitest or Jest. Data functions can be tested separately as plain async code.