With the cypress code snippet given below, I visit a homepage and then click on a profile button which shows the profile in the side of the home page (not in a separate page). Is it ok to wait like this or are there serious problems in my approach ?
MyHomePage.clickProfileButton();
ProfileStubUtil.waitForGetProfileApi();
waitForGetProfileApi(): Cypress.Chainable<Interception> {
const wait = cy.wait("@getProfile");
return wait;
}
I heard that we could chain the wait off the action which needs to wait i.e.
MyHomePage.clickProfileButton()
. So, that would become something like MyHomePage.clickProfileButton().wait("@getProfile");
. Is this any better than what I have done if yes/no, then why?