Testing · Middle · Question 21 of 75
How do you render a component that needs providers (router, store, query client)?
function renderWithProviders(ui: ReactElement) {
return render(ui, { wrapper: AppProviders });
}- ✓Correct answer: Create a custom render with the
wrapperoption and reuse it in all tests - 2Mock every hook the component uses
- 3Render the whole
Appin each test
Explanation
Testing Library docs recommend re-exporting a custom render from a test utils module.