title: jest unit test for AWS lambda
body: <p>I am new to Node.js. I was trying to write a jest unit test cases for AWS lambda function(for node environment). I used a node module called "lambda-tester" to test it. But the problem with "lambda-tester" is, it will hit the actual service and return the data. I don't want to do that. I need to mock the service call.</p>
  
  <p>So, I wanted to go with the plain old way. But, I have issues with mocking it. Can you help me to write basic unit test case for the below lambda ith mocking the function "serviceFunction" ?</p>
  
  <pre class="lang-js prettyprint-override"><code>const dataService = require('../dataService');
  
  exports.lambdaService = async event =&gt; {
    let response = await serviceFunction(event.id);
    if (response.code == 200) {
      return response;
    } else {
      return {
        statusCode: response.code,
        body: JSON.stringify({
          message: response.message
        })
      };
    }
  };
  
  const serviceFunction = async id =&gt; {
    return await dataService.retrieveData(id);
  };
  </code></pre>