title: Jest mocking of classes with DI dependencies
body: <p>Various Jest docs show creation of "automatic" mocks, "manual" mocks, or <a href="https://jestjs.io/docs/en/es6-class-mocks.html" rel="noreferrer">ES6 class</a> mocks (which instantiate dependencies within the constructor).</p>
  
  <p>But I want to use DI / IOC and inject dependencies into the ctor:</p>
  
  <pre><code>// IBar.ts                                           &lt;--- mock this
  export default interface IBar {
    /* ...methods... */
  }
  
  // Baz.ts                                            &lt;--- mock this
  export default class Baz {
    constructor(spam: Spam, ham: IHam) { /* ... */}
    /* ...other methods... */
  }
  
  // Foo.ts                                            &lt;--- test this
  export default class Foo {
    constructor(bar: IBar, baz: Baz) { /* ... */}
    /* ...other methods... */
  }
  </code></pre>
  
  <p>So I want to do this in a test:</p>
  
  <pre><code>const barMock = jest.giveMeAMock("../../IBar");  // or jest.giveMeAMock&lt;IBar&gt;();
  const bazMock = jest.giveMeAMock("./Baz");       // or jest.giveMeAMock&lt;Baz&gt;();
  const foo = new Foo(bar, baz);
  
  expect(foo.something()).toBe(true);
  </code></pre>
  
  <p>Is this possible with Jest?</p>
  
  <p>(I used some TypeScript syntax above, but it's the same problem for JS/ES6 and TS.)</p>