Cypress tests passing in GUI failing in CI

Viewed 186

I'm testing the change in visibility of an element when the page scrolls. In the cypress GUI this test passes everytime.

enter image description here

Yet it fails everytime when run on the command line / in CI:

  home page desktop
    ✓ desktop: top section info (1923ms)
    1) desktop: use cases info


  1 passing (18s)
  1 failing

  1) home page desktop
       desktop: use cases info:
     AssertionError: Timed out retrying after 15000ms: expected '<span.css-ifijsl>' to be 'visible'

This element `<span.css-ifijsl>` is not visible because its parent `<div.css-1nm341b>` has CSS property: `opacity: 0`

This is the assertion with the helper function:

function scrollIntoView(dataTestId: string) {
  // fix for the issue with cypress scroll
  return cy
    .get(`[data-testid=${dataTestId}]`)
    .should('exist')
    .then(el => {
      el[0].scrollIntoView({ block: 'nearest' })
      return el
    })
}

function checkUseCasesVisibility() {
  cy.findByTestId('homepage-use-case-1').should('not.be.visible')
  scrollIntoView('abcde')
  cy.findByTestId('homepage-use-case-1').should('be.visible')

cypress config

{
  "baseUrl": "http://controld-webapp:9000",
  "integrationFolder": "cypress/e2e/build/cypress/e2e",
  "viewportHeight": 900,
  "viewportWidth": 1440,
  "defaultCommandTimeout": 15000,
  "requestTimeout": 15000,
  "video": false,
  "chromeWebSecurity": false,
  "scrollBehavior": "center"
}
0 Answers
Related