Skip to content
Testing·Intermediate·Conceptual·1 min read

How do you correctly test asynchronous UI, like content that appears after a fetch?

Short interview answer

Use an async query such as findByText or findByRole, which retries until the element appears or times out, or wrap an assertion in waitFor. Avoid fixed setTimeout delays, which are slow when long and flaky when short.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Testing React components

Related questions