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

How should you render a component that depends on context or a router?

Short interview answer

Wrap it in the real providers it needs, ideally through a custom render helper that applies the app's standard provider stack. Mocking context values is acceptable for isolating a specific state, but real providers catch integration issues a hand-built mock value would miss.

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