title: How to compare promise results with Chai as Promised
body: <p>I'm just getting started with Mocha, Chai and Chai as promised. I'm creating a test framework that reads in a series of test files, runs them through a parsing process, and compares the results with some saved outputs in parallel files in the same directory.</p>
  
  <p>My initial stab at this looked like:</p>
  
  <pre><code>var files = glob.sync('./tests/data/*.txt');
  files.forEach(function(file) {
  
      it("correctly parses " + file.replace( /\.txt$/,''), function(){
          return runTestForFile(file).should.eventually.deep.equal(
                       getExpectedOutputForFile(file));
      });
  
  });
  </code></pre>
  
  <p>Where both runTestForFile and getExpectedOutputForFile return promises. I'm using bluebird, if that makes any difference. This failed with comparison errors. The actual value come up as one of my objects, as expected, but the expected value, as returned by getExpectedOutputForFile, come up as an object dump of a promise. I was a bit surprised because I assumed that by using chai-as-promised this would just work. Doing:</p>
  
  <pre><code>it('test', function() {
      Promise.resolve(2).should.eventually.equal(Promise.resolve(2));
  });
  </code></pre>
  
  <p>works fine. In the end I got it working by adding:</p>
  
  <pre><code>chaiAsPromised.transformAsserterArgs = function (args) {
      return Promise.all(args);
  };
  </code></pre>
  
  <p>but I have no idea why this is necessary or how it really changes things! Can someone explain what I'm missing/suggest a better way of doing this?</p>