title: Using Jasmine's spyOn / andReturn to mock fs.readFileSync()
body: <p>I'm trying to mock the response of fs.readFileSync() so I can test that my code is returning some data in my config file. Obviously I don't want to be testing the contents of my config file.</p>
  
  <p>I'm trying to test this code in (api.js)</p>
  
  <pre><code>var fs = require('fs');
  var config = JSON.parse(fs.readFileSync('configure.json', 'utf8'));
  
  var Api = {
      api_key: config['api-key'],
      heartbeat_id: config['resource-id'],
  };
  </code></pre>
  
  <p>If I can mock what <code>fs.readFileSync</code> returns then I can have it return some test values. My test looks like this:</p>
  
  <pre><code>var api = require('./api');
  var fs = require('fs');
  
  describe('Api object contains correct details', function(){
      it('Has an API key of "test API"', function(){
          spyOn(fs, 'readFileSync').andReturn(`{
              "api-key": "test API",
              "resource-id": "Resource ID"
          }`);
          expect(api.api_key).toBe("test API");
      });
  });
  </code></pre>
  
  <p>The test is failing and returning the value in my actual config file.</p>