Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
cypress get method can not get data-cy at my component

cy custom method

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

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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!

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!