title: Jest Mock Promise with Params
body: <p>This is the method I am trying to write Unit test in Jest </p>
  
  <pre class="lang-js prettyprint-override"><code>async function getParameter(parameter: string,
    withDecryption: boolean = false): Promise&lt;String&gt; {
  
    const params = {
      Name: parameter,
      WithDecryption: withDecryption,
    };
    try {
      const request = await       ssmClient.getParameter(params).promise();
  
      return request.Parameter.Value;
    } catch (err) {
      logger.error(`Error ${err}`);
      throw Error(err);
    }
  }
  </code></pre>
  
  
  
  <p>Test Method : </p>
  
  <pre class="lang-js prettyprint-override"><code>test('getParameterFromSystemManager', async () =&gt; {
    const mockedResponseData = {
      Parameter: {
        Value: 'parameterValue',
      },
    };
  
   ssmClient.getParameter(params).promise = jest.fn();
  
   ssmClient.getParameter(params).promise.mockImplementation(() =&gt; Promise.resolve(mockedResponseData));
  
   const data = 
   await SSMParameters.getParameterFromSystemManager('testurl', false, 
   'Test', 'elastic');
   expect(data).toEqual(mockedResponseData.Parameter.Value);
   expect(ssmClient.getParameter).toHaveBeenCalledTimes(1);
  });
  </code></pre>
  
  
  
  <p>I get the error : </p>
  
  <p><strong>TypeError: 
  ssmClient.getParameter(...).promise.mockImplementation is not a function</strong></p>
  
  <p>How do we mock such .promise() functions in Jest ?</p>