I am trying some UI tests on Cypress and would like to continue this discussion mentioned here in SO.
I have a table like this but would like to sort based on column say A or B.
I followed the solution mentioned in the link but getting assertion failure - expected [ Array(3) ] to deeply equal [ Array(3) ]
function getCellTextAsArray(){
let cellContents = []
return new Cypress.Promise(resolve => {
cy.get('#datatable-tabletools').find('tbody').children()
.each(($el, $index) => {
//some logic to select the elements you want
//like $index % 4 == 0
if($index>=0) {
cellContents.push($el.text())
}
}).debug()
.then(() => resolve(cellContents))
})
}
and then call this function as
getCellTextAsArray()
.then(cellContents => {
let actual = cellContents.slice()
cy.wrap(actual)
.should('deep.eq', cellContents.sort())})
Apologies, I am new to javascript.