I would like to return table data in human readable format using Cypress (without Cy wrappers).
Suppose we have such a table:
| Col1 | Col2 | Col3 |
|---|---|---|
| D1 | D3 | D5 |
| D2 | D4 | D6 |
This is my code but I don't know how to get the real data:
getTableData() {
return cy.get('#table-modal')
.then(modal => cy.wrap(modal).find('table > tbody > tr'))
.each(row =>
cy
.wrap(row)
.find('td')
.each(column => cy.wrap(column).invoke('text'))
);
}
const expected = [
['D1', 'D3', 'D5'],
['D2', 'D4', 'D6']
];
getTableData().should('eq', expected); // failing, because function returns wrapped data by Cypress