Testing · Senior · Question 36 of 75
How do you unit-test a Next.js Server Action?
- ✓Correct answer: Call it as a regular async function with mocked boundaries (database,
cookies,revalidatePath), and cover the form flow with E2E - 2Only via a real browser
- 3Server Actions can't be imported in tests
Explanation
Keep validation and business logic in plain functions; the action stays a thin adapter.