title: Wait for an own function (which returns a promise) before tests are executed
body: <p>I'm new to cypress and am trying to figure out how things work.</p>
  
  <p>I have my own function (which calls a test controller server to reset the database). It returns a promise which completes when the DB have been successfully resetted.</p>
  
  <pre><code>function resetDatabase(){
    // returns a promise for my REST api call.
  }
  </code></pre>
  
  <p>My goal is to be able to execute it before all tests.</p>
  
  <pre><code>describe('Account test suite', function () {
  
    // how can I call resetDb here and wait for the result
    // before the tests below are invoked?
  
    it('can log in', function () {
          cy.visit(Cypress.config().testServerUrl + '/Account/Login/')
  
          cy.get('[name="UserName"]').type("admin");
          cy.get('[name="Password"]').type("123456");
          cy.get('#login-button').click();
    });
  
    // .. and more test
  
  })
  </code></pre>
  
  <p>How can I do that in cypress?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I've tried</p>
  
  <pre><code>  before(() =&gt; {
      return resetDb(Cypress.config().apiServerUrl);
    });
  </code></pre>
  
  <p>But then I get an warning saying:</p>
  
  <blockquote>
    <p>Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise</p>
  </blockquote>
  
  <p>I'm not invoking <code>cy</code> in <code>resetDb()</code>.</p>