title: NodeJS fs.appendFile not working within promise in mocha
body: <p>I want to keep a log during my integration test suite. I'm testing that every 'item' is being compiled and logging how much time it took. I'm using <strong>node 4.3</strong>.</p>
  
  <p>First of all I create the log file:</p>
  
  <pre><code>before(function() {
      if (!fs.existsSync("./log.csv")) {
          fs.writeFile("./log.csv", "Name; Time");
      }
  });
  </code></pre>
  
  <p>Then within each <code>it</code> block I would do this:</p>
  
  <pre><code>for (const item of items) {    
      it('compiles', function() {
          return item.testCompile();
      });
  }
  </code></pre>
  
  <p>And <code>item</code> class has these methods:</p>
  
  <pre><code>testCompile() {
      return this
          .buildItem()
          .then(result =&gt; {
              // whatever testing stuff
          });
  }
  
  buildItem() {
      return this
          .internalLogicForCompiling()
          .then(result =&gt; {
              // This is not appending anything 
              fs.appendFile("./log.csv", `${item.name}; ${result.compileTime}`);
  
              return result;
          });
  }
  </code></pre>
  
  <p>So far the file is created but never updated... Any clue what I'm doing wrong?</p>
  
  <p>PS: I assume if the file doesn't exists, <code>fs</code> should throw an error, however it doesn't.</p>