Skip to content

How to clear search from location after/before each test? #17645

Discussion options

You must be logged in to vote

A few things:

  1. Component testing doesn't need to use cy.window() or cy.location() like E2E does.

Cypress Component Testing executes in the same window instance as the spec, which means that you can do everything you'd usually do in a webpage inside of Cypress.

  1. If you modify document.location.search programmatically to reset it between tests, it will trigger a full-page refresh and you will lose your spec page.

You need to use a <MemoryRouter> instead of the real document.location or window.history.

  1. If you want to test real multi-page navigation, you need to use E2E tests.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mufasa71
Comment options

Answer selected by mufasa71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants