title: In Jest, how do you mock a TypeScript class with dependencies?
body: <p>Given this relatively contrived class that gets a single record from Elasticsearch (or any datastore for that matter):</p>
  <pre><code>export default class UserRepoImpl implements UserRepo {
    constructor(private readonly esClient: ElasticsearchClient) {}
  
    public async getUser(id: string): Promise&lt;User&gt; {
      const response = await this.esClient.request('GET', `/users/_doc/${id}`);
  
      return response._source;
    }
  }
  
  </code></pre>
  <p>How do I write a test that will instantiate a <code>UserRepoImpl</code> for me but insert a <em>mocked ElasticsearchClient</em> as the argument to the constructor?</p>