title: How to fix warning "Cypress detected that you returned a promise in a test"
body: <p>I'm writing a test in cypress that checks that a new item was added to the list. I don't want to hardcode the length, I'd like to confirm that the size of the list increased by one. This code works:</p>
  
  <pre><code>  beforeEach(() =&gt; {
      cy.visit('/page/1');
    });
  
    it('happy path comments', async function() {
      cy.get('[data-cy=commentList]').should('have.length', 1);
      const list = await cy.get('[data-cy=commentList] [data-cy=comment]');
      const beforeLength = list.length;
      cy.get('[data-cy=commentBody]').type('foobar');
      cy.get('[data-cy=submit]').click();
      cy.get('.[data-cy=commentList] [data-cy=comment]').should(
        'have.length',
        beforeLength + 1
      );
      cy.get('[data-cy=commentBody]').should('have.value', '');
    });
  
  </code></pre>
  
  <p>However, this generates the following warning:</p>
  
  <blockquote>
    <p>cypress_runner.js:84852 Cypress Warning: Cypress detected that you
    returned a promise in a test, but also invoked one or more cy commands
    inside of that promise.</p>
    
    <p>The test title was:</p>
    
    <blockquote>
      <p>Comments happy path comments</p>
    </blockquote>
    
    <p>While this works in practice, it's often indicative of an
    anti-pattern. You almost never need to return both a promise and also
    invoke cy commands.</p>
  </blockquote>
  
  <p>How can I fix this warning?</p>