Cypress is really a cool tool and the below thing is stopping me from migrating scripts from protractor to cypress..
this.getBreadcrumText = async (value) => {
const a = await cy.xpath("//*[contains(@data-testid,'breadcrumbs-route-Dashboards')]")
.text().then(txt => {
expect(txt).equal('Dashboards')
});
cy.log('------', a)
}`
In the above method I was able to expect the text within the page. If I want to do assertions in the spec level I should be able to return the value of a to the spec file where this function is called, which is currently not happening. Ideally in the test/spec file we should not be using the element references also.
Basically in spec file if I use
expect( dashboardPage.getBreadcrumText()).equal('Dashboards')
it is not working. Any way to achieve this?