title: Mock Slack Web Api Jest
body: <p>I have two files, one in which I initialize a slack web API client, and post a message, and test this based on a mocked value:</p>
  <p><code>main.ts</code>:</p>
  <pre><code>import { WebClient } from '@slack/web-api';
  const slack = new WebClient(process.env.SLACK_API_KEY as string);
  
  slack.chat.postMessage({...});
  </code></pre>
  <p><code>test.ts</code></p>
  <pre><code>import { WebClient } from '@slack/web-api';
  let slack: WebClient;
  
  beforeAll(async () =&gt; {
    slack = new WebClient();
  });
  
  jest.mock('@slack/web-api', () =&gt; {
    return {
      chat: jest.fn(),
      postMessage: jest.fn(),
    };
  });
  
  describe('test', () =&gt; {
    it(&quot;tests slack message&quot;, async () =&gt; {
      expect(slack.chat.postMessage).toBeCalledWith({...});
    })
  })
  </code></pre>
  <p>The problem is when I run this code I get the following error: <code>TypeError: web_api_1.WebClient is not a constructor</code></p>
  <p>I've tried various different ways including mocking the module, using <code>esModule: true</code>, not defining WebClient. My question is what am I doing wrong?</p>