Cypress · Middle · Question 31 of 77
How do you mount a React component that needs a router and store in component tests?
- 1Component tests can't use providers at all
- 2Wrap it in providers in a custom
mountcommand - 3Start the whole app and navigate to the component
Show the answer
Correct answer: Wrap it in providers in a custom mount command
Explanation
A custom cy.mount that wraps components with router, theme and store providers keeps each test short.