Here is the code for the online tutorial to get title of elements:
test.js
it('',function(){
        cy.visit("https://www.simplyrecipes.com/")
        new SRHomePage().getHeroComponentTitle2().then(title => {
           cy.log(title);
        });
    });
SRHomePage.js
export class SRHomePage{
    getHeroComponentTitle2(){
        let title = '';
         cy.get('.showcase__hero .card__title').then($title => {
            title  = $title.text().trim()
        });
        return new Cypress.Promise(resolve => {
            cy.wrap('').then(() => resolve(title))})
    }
}
IN SRHomePage.js, when I use
return new Cypress.Promise(resolve => {
                cy.wrap('').then(() => resolve(title))})
        } 
=> get title
Order is:
1 visithttps://www.simplyrecipes.com/
2 get.showcase__hero .card__title
3 wrap
4 log Gruyère Mushroom Pizza With Balsamic Glaze
If I use
return new Cypress.Promise(resolve => resolve(title))
=> Do not get title
Order is
1 visithttps://www.simplyrecipes.com/
2 log
3 get.showcase__hero .card__title
I really confused the way work for Promise, cy.wrap('') and asynchronous handling in Cypress in this sittuation
Please explain to me, I really know to understand, thank a lot
