title: What is a real-world way of allowing a mocha test to stub/mock fs so I can test a function without it accessing the disk?
body: <p>So my code looks like this:</p>
  
  <pre><code>import FsAsyncFactory from '../fs/FsAsyncFactory'
  import ObjectHelper from '../utils/ObjectHelper'
  import Config from './Config'
  
  export class ConfigHelper {
  
      // this is the function under test
      public static async primeCacheObj(): Promise&lt;void&gt; {
  
          const configFileObj: any = await ConfigHelper.getConfigFileObj()
  
      }
  
      private static configCacheObj: Config = null
  
      private static async getConfigFileObj(): Promise&lt;any&gt; {
          const fsAsync: any = FsAsyncFactory.getFsAsync()
          const fileContents: string = await fsAsync.readFileAsync('./config/hubnodeConfig.json')
  
          return JSON.parse(fileContents)
      }
  
  }
  
  export default ConfigHelper
  </code></pre>
  
  <p>What's the best way to allow my unit testing code to stop it from actually hitting the disk?</p>
  
  <p>Should I be using something like InversifyJS to allow dependency injection? I'd have an init script that would setup the "defaults" for when the app is running normally then "override" those defaults in the tests?</p>