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