title: How to mock (change value) of global variables in javascript using jest/sinon etc?
body: <p>I'm writing test cases for a ts file which contains a global variable like so:</p>
  <pre><code>let cachedSecret: any;
  
  const find = () =&gt; {
     if(cachedSecret){
       //return something
     } else {
         //return something else
     }
  }
  </code></pre>
  <p>I need to find a way so that for one of the test cases I can mock cachedSecret's value as some string and in the other test case it's value should be null.</p>
  <p>I'm using jest and sinon but I haven't been able to find a way to do this.</p>
  <p>Thanks</p>