title: Jest and Typescript - Mocking a const in a function
body: <p>New to Jest here and not sure how I would do this:</p>
  
  <p>Say I have some function that contains a <code>const</code> that I've set to a specific type (<code>newArtist</code>):</p>
  
  <pre><code>export class myTestClass {
      async map(document: string) {
          const artist: newArtist = document.metadata.artist;
          ...
          }
  }
  </code></pre>
  
  <p>And along with that I have:</p>
  
  <pre><code>export interface newArtist {
      name: string;
      title: string;
  }
  </code></pre>
  
  <p>Now when I write a test, if I do say something like:</p>
  
  <pre><code>it("My example test", async () =&gt; {
      const result: any = await new myTestClass(__context()).map({
          name: "An Artist"
          title: null
      });
          ...
  }
  </code></pre>
  
  <p>The test will fail because <code>title</code> is set to null. I need that interface to be a little different for the purposes of the test - basically to be be something like:</p>
  
  <pre><code>export interface newArtist {
      name: string;
      title: string | null;
  }
  </code></pre>
  
  <p>How can I do that? I've seen mocking classes, but wouldn't that mean I end up copying/pasting all the <code>map</code> function code?</p>
  
  <p>Any help appreciated.</p>
  
  <p>Thanks.</p>