title: Creating a cypress custom command for getting text in typescript
body: <p>i am working on a cypress project and I am trying to create a custom command 
  which resolves promise and returns text on the passed locator.</p>
  
  <pre><code>export default class QuickRegisterPage {
    emailAddressText() {
      return cy.get('#emailAddress');
    }
  
  public createNewUser() {
      cy.getQuickRegisterUrl().then(url =&gt; {
        cy.visit(url);
        text = cy.getText(this.emailAddressText());
        cy.log(text);  
        });
  }
  
  
  Cypress.Commands.add(
    'getText',
    (element: Cypress.Chainable&lt;JQuery&lt;HTMLElement&gt;&gt;) =&gt; {
      element.scrollIntoView();
      element.then(ele =&gt; {
        const text = ele.text();
        return text;
      });
    }
  );
  
  declare namespace Cypress {
    interface Chainable&lt;Subject = any&gt; {
      getText(element: Cypress.Chainable&lt;JQuery&lt;HTMLElement&gt;&gt;): string;
    }
  }
  </code></pre>
  
  <p>when I am calling <code>cy.getText()</code> nothing is happening it's just sitting there and not returning the text.</p>
  
  <p>can someone help me to resolve this.</p>