title: How do you specify the code behind the mocked AWS Lambda
body: <p>I'm currently in the phase of unit-testing my lambdas and this is the first time I'm doing this, so please bear with me.</p>
  <p>I've done my researches about this, and I think I managed to pinpoint down to which package I should use and which method.</p>
  <p>As far as I know, <code>aws-sdk-mock</code> is the way to go. It seems complete and well-documented, so there's no problem in that direction. The only issue I have with it is the lack of documentation for AWS Lambda Invoke mockings.</p>
  <p>The main issue I have is with mocking a specific function whose code is stored in the same project as the test.</p>
  <p>i.e: I have a <code>lambda.ts</code>:</p>
  <pre><code>export const handler: APIGatewayProxyHandlerV2 = async (event: any) =&gt; {
      const body = event.body;
      //do things with body
      return {
        statusCode:200,
        body: &quot;OK&quot;
      }
  }
  </code></pre>
  <p>How do I correctly mock this?
  I started a <code>lambda.test.ts</code> that looks like this :</p>
  <pre><code>import AWSMock from &quot;aws-sdk-mock&quot;
  import AWS from &quot;aws-sdk&quot;
  
  beforeAll(async (done) =&gt; {
    //get requires env vars
    done()
  })
  
  describe(&quot;Calling lambda&quot;, () =&gt; {
    it(&quot;should reject API call because of missing arguments&quot;, async () =&gt; {
      AWSMock.setSDKInstance(AWS)
      AWSMock.mock(&quot;Lambda&quot;, &quot;invoke&quot;, async (params, callback) =&gt; {
          const lambda = new AWS.Lambda()
          await lambda.invoke({
              FunctionName: 'lambda',
              ...?
          }).promise()
      })
    })
  })
  
  </code></pre>
  <p>I don't know how to indicate that the code that's behind this mocked lambda is available somewhere.</p>
  <p>Thanks in advance for your help!</p>