I have tree value on my page. After one event these tree values should change. I want to get the initial value of them, then after the event, I would like to see if they increased correctly. Can I read and save these tree values without chaining them into each other?
The current code is now:
let active_tours: number;
let active_drivers: number;
let total_capacity: number;
cy.get('[data-cy="txt-dashboard-active_tours"]')
.invoke('text')
.then((txt) => {
active_tours = parseInt(txt, 10);
cy.get('[data-cy="txt-dashboard-active_drivers"]')
.invoke('text')
.then((txt) => {
active_drivers = parseInt(txt, 10);
cy.get('[data-cy="txt-dashboard-total_capacity"]')
.invoke('text')
.then((txt) => {
total_capacity = parseInt(txt, 10);
cy.createTour('email', 'password').then(
(response: any) => {
cy.get('[data-cy="txt-dashboard-active_tours"').should(($div) => {
expect($div.text().trim()).equal((active_tours + 1).toString());
});
cy.get('[data-cy="txt-dashboard-active_drivers"').should(($div) => {
expect($div.text().trim()).equal((active_drivers + 1).toString());
});
cy.get('[data-cy="txt-dashboard-total_capacity"').should(($div) => {
expect($div.text().trim()).equal(
(total_capacity + response.vehicle.capacity).toString()
);
});
}
);
});
});
});