title: Mock imported class in typescript with jest
body: <p>I am trying to use jest to mock an imported class inside a typescript class, the following code is used for the main program(I removed some code from inside the functions but it shoud still be clear what I am trying to do)</p>
  
  <pre><code>import * as SocketIO from "socket.io";
  
  import {AuthenticatedDao} from "../../dao/authenticated.dao";
  
  export default class AuthenticationService {
      private readonly _authenticatedDao: AuthenticatedDao = AuthenticatedDao.Instance;
      private readonly _io;
  
      constructor(socketIo: SocketIO.Server) {
          this._io = socketIo;
      }
  
      public authenticateUser(username: string, password: string, clientSocketId: string): void {
          this._authenticatedDao.authenticateUser(username, password).then((authenticatedUser) =&gt; {
  
          }).catch(rejected =&gt; {
  
          });
      }
  }
  
  
  import {createServer, Server} from 'http';
  import * as express from 'express';
  import * as socketIo from 'socket.io';
  import {LogincredentialsDto} from "./models/dto/logincredentials.dto";
  import {config} from './config/config';
  import AuthenticationService from "./services/implementation/authentication.service";
  import {Logger} from "./helperclasses/logger";
  import {format} from "util";
  
  export class ClassA {
      private readonly _configPort = config.socketServerPort;
  
      private readonly _logger: Logger = Logger.Instance;
      private _app: express.Application;
      private _server: Server;
      private _io: socketIo.Server;
      private _socketServerPort: string | number;
      private _authenticationService: AuthenticationService;
  
  
      constructor() {
          this.configure();
          this.socketListener();
      }
  
      private configure(): void {
          this._app = express();
  
          //this._server = createServer(config.sslCredentials, this._app);
          this._server = createServer(this._app);
  
          this._socketServerPort = process.env.PORT || this._configPort;
          this._io = socketIo(this._server);
  
          this._server.listen(this._socketServerPort, () =&gt; {
              this._logger.log(format('Server is running on port: %s', this._socketServerPort));
          });
  
          this._authenticationService = new AuthenticationService(this._io);
      }
  
  
      private socketListener(): void {
          this._io.on('connection', (client) =&gt; {
                  client.on('authenticate', (loginCreds: LogincredentialsDto) =&gt; {
                      console.log(loginCreds.username, loginCreds.password, client.id);
                      this._authenticationService.authenticateUser(loginCreds.username, loginCreds.password, client.id);
                  });
              }
          );
      }
  }
  </code></pre>
  
  <p>I am trying to mock the function "authenticateUser" in "AuthenticationService", instead of calling the normal code I want to mock the promise. I tried using the examples provided in <a href="https://jestjs.io/docs/en/es6-class-mocks" rel="noreferrer">https://jestjs.io/docs/en/es6-class-mocks</a> but when I try doing the following:</p>
  
  <pre><code>import AuthenticationService from '../src/services/implementation/authentication.service';
  jest.mock('./services/implementation/authentication.service');
  
  beforeEach(() =&gt; {
      AuthenticationService.mockClear();
  });
  
  it('test', () =&gt; {
  
      // mock.instances is available with automatic mocks:
      const authServerInstance = AuthenticationService.mock.instances[0];
  </code></pre>
  
  <p>I get this error:
      Error:(62, 31) TS2339: Property 'mock' does not exist on type 'typeof AuthenticationService'.</p>
  
  <p>What am I doing wrong here? Should I be mocking the class/function differently since it's using promises?</p>