Interview practice question
Testing a modal rendered in a portal
Frontend Engineering · Testing and Tooling · Intermediate
Your tests can't find content inside a modal that renders through a portal. How would you test it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Query screen (document.body), not container.
- Use role="dialog" queries.
- Test open/close, focus, Escape.
- Ensure portal root exists in test DOM.
- Accessible queries.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.