vendredi 30 août 2019

Cypress, read the data from API response

All of the example I found are with calling the API and defining method and URL. For example

  cy.server()

  cy.route({
    method: 'GET',
    url:'https://www.something.com, 
    }).as('get_jobs')

  cy.get('[data-cy="job-search-input"] button').click()

  cy.wait('@get_jobs').then((xhr) => {
     cy.log(xhr.response.body.data)
  })

What I want is just to select the button, press click and read the response that it gives me. I don't wanna define url again, but use the one that is already used in the code and just check the response that it gives me after pressing the button.

How can I do that?

Aucun commentaire:

Enregistrer un commentaire