0

I have a button with Link tag and routes to a new url and content onClick, basically calls a function.

I wanted to know if I can test whether the url is changed/new content is displayed post click, but I am not able to do so with 'simulate'. Is it possible to check that using jest/enzyme?

CVKM
  • 113
  • 1
  • 6

1 Answers1

0

I view you can test that using E2E testing.

I prefer https://www.cypress.io/, it is very easy for testing URL changing.

cy.getByTestId('your_button')
  .click()
  .url()
  .should('include', 'expected_url')

FYI: https://docs.cypress.io/api/commands/url.html#No-Args

Thaddeus Jiang
  • 172
  • 1
  • 8