Cypress.Commands.add('shouldRenderShowcase', ({ name, highlight = false }) => {
cy.getByDataCy(name).within(() => {
cy.findByRole('heading', { name }).should('exist')
cy.getByDataCy('game-card').should('have.length.gt', 0)
cy.getByDataCy('highlight').should(highlight ? 'exist' : 'not.exist')
if (highlight) {
cy.getByDataCy('highlight').within(() => {
cy.findByRole('link').should('have.attr', 'href')
})
}
})
})
Guys, i have this custom method to check my component that calls Showcase. As you can see, i have another custom method inside, which calls getByDataCy, its the same as cy.get
, but i dont need to pass content inside the []
.
I this test, i have been looking for a component, inside the showcase which calls game-card, but the cypress does not find it.
As you can see in the image below, there is cy="game-card"
inside the article tag. I dont know why the cypress did found it. Can you help me?
cy does not find data-cy, but there is a data-cy in html tree
I found the error. I have three test that call this method, and one of those there were no games in it, but the message was seems like for everyone. The error was because my backend could not find new released games. Thank you for your time!