title: How to use jest to mock out a private variable
body: <p>I am trying to write a unit test for a function like this:</p>
  
  <pre><code>export class newClass {
      private service: ServiceToMock;
  
      constructor () {
      this.service = new ServiceToMock()
      }
  
      callToTest () {
          this.service.externalCall().then(()=&gt; {
          //Code to test
          })
      }
  }
  </code></pre>
  
  <p>In order to test this piece of code I need to mock out service because it calls a function outside of the class but the problem is it's private.</p>
  
  <p>How exactly do I mock out a private variable with jest?  The class creates its own instance of it so is it even possible to mock out?</p>