I need to choose several elements in filter and check that the data would be shown according the filter. I'm trying to save text of elements in the variables, and check it at the end.
it.only('the UI with a lot of entries in a filter, should be responsive', () => {
  let listItem1
  let listItem2
  cy.get('someTab').click().then(()=> {
    cy.getText(cy.get('someSelector').first(), listItem1)
    cy.getText(cy.get('someSelector').last(), listItem2)
  }).then(()=> {
    cy.get('someSelector').first().click()
    cy.get('someSelector').last().click()
    cy.get('someButton').click()
  }).then(()=>{
    cy.log(listItem1, listItem2)  // nothing is visible
    cy.get('span[data-app]').should('contain', listItem1)  // fail
    cy.get('span[data-app]').should('contain', listItem2)  // fail
  })
})
I use this function:
getText(selector, variable) {
  return selector.invoke('text')
    .then(($text) => {
      variable = $text.trim()
    })
}  
It doesn't work, but I can't to understand how to fix it
 
    