title: Mocha test timeouts when testing length of array
body: <p>I'm testing a little node module with mocha and expect.js and I'm having a bit of a headache. </p>
  
  <p>This is the test definition: </p>
  
  <pre><code>it('Should return an expansion array that contains all the objects that comes along within a single group', function (done) {
  
    visibility.expand(data, config.data, companies, groups, function (error, expansion) {
  
      expect(error).to.be(null);
      expect(expansion).to.be.an('array');
      expect(expansion).to.have.length(2);
      expect(expansion.toString()).to.eql([testCompaniesIds[2], testCompaniesIds[3]].toString());
  
      done();
    });
  });
  </code></pre>
  
  <ul>
  <li><strong>data</strong> is a wrapper for database access and functionality. I initialize it in the <em>before</em> method of my test suite.</li>
  <li><strong>config.data</strong> holds an object with config params (not relevant)</li>
  <li><strong>companies</strong> is an array of strings</li>
  <li><strong>groups</strong> is an array of strings</li>
  </ul>
  
  <p>The problem that i'm facing is that when Mocha reaches this line</p>
  
  <pre><code>expect(expansion).to.have.length(2);
  </code></pre>
  
  <p>and the length is different from 2, instead of throwing an error like: Expected 2 but length was 1 it simply stops and throw an error because of the timeout. </p>
  
  <p>I verified that the test executed until that line. </p>
  
  <p>A bit more of information: the method that I'm testing receives an array of company names and an array of group names. Each group contains an array of company database id's. </p>
  
  <p>The expected behaviour of the method is to return an array with corresponding company id's merged with the array of company id's belonging to the group object.</p>
  
  <p><strong>Edit 2</strong> due to possible duplicate: I was wrong. It was indeed executing in the scope of a promise.</p>
  
  <p><strong>Edit</strong> due to possible duplicate: the expectation in not executing in the scope of a promise (when using promises and executing expect in either resolve or reject functions is the promise who catch the error).</p>
  
  <p>Thanks in advance!</p>