title: Mocha preserve file state in test
body: <p>I have a unit test that is testing updating of a config file...  Of course after I run the test my file is now altered.  I was thinking I could use "before" to cache the file and restore it on "after".  </p>
  
  <pre><code>mod = require('../modtotest');
  
  describe('Device Configuration', function(){
    var confPath = '../config/config.json';
    var config;
  
    before(function(){
      //cache object
      config = require(confPath);
    })
  
    describe('Update Config', function(){
      it('Should update config', function(done){
          mod.updateConfig();
          //do assertions
      })
    });
  
    after(function(){ 
      //restore
      fs.writeFileSync(confPath, JSON.stringify(config, null, 4));
    })
  
  })
  </code></pre>
  
  <p>However whenever I try to do this it says the file does not exist.  It appears that when I run Mocha (<code>-&gt; app $mocha -R spec</code>), it executes out of the global install directory inside of where I execute it? </p>
  
  <p>Is there a easy way to achieve what I want?  Or am I maybe just going about it all wrong?</p>