title: How to mock the instance function of another class using Jest
body: <p>I have two classes for eg: </p>
  
  <pre><code>//MyClass.ts
  import {B} from '../MyAnotherClass'
  class A {
    f1(){ }
    f2(){ 
      const instance = new B();
      instance.someBFunctionFoo(arg);
    }
  }
  
  // MyAnotherClass.ts
  class B {
    someBFunctionFoo(arg){ }
    someBFunctionBar(){ }
  }
  </code></pre>
  
  <p>I want to write test cases for class A but i don't want class A to actually invoke class B instance functions rather call a mocked version of those functions. How can this be achieved using Jest. I am using typescript and running test cases against the typescript rather the compiled js files.  </p>