dimanche 13 septembre 2020

need to load data at Angular page load in cypress

I'm trying to test an Angular app page using cypress. During the page's ngOnIt, data is loaded from the backend which dynamically loads images into a div. Cypress checks to see if one of these images exist using the image id.

Here is the cypress code:

cy.get('button[type=submit]').click();
cy.get('app-picture-authenticate').should('exist'); // This is when the images load
cy.get(`img[id=${pic}]`).click(); // cypress can't find image

Since the backend doesn't run during the cypress test I need to load the data somehow. I know in cypress you can use fixtures to load data from XHR requests but how would I do that for an Angular ngOnIt page load?

Aucun commentaire:

Enregistrer un commentaire