moromi-aws-lambda-edge

aws lambda@edge plugin for moromi

Usage no npm install needed!

<script type="module">
  import moromiAwsLambdaEdge from 'https://cdn.skypack.dev/moromi-aws-lambda-edge';
</script>

README

moromi-aws-lambda-edge

aws lambda@edge plugin for moromi

Installation

  yarn add moromi-aws-lambda-edge

Usage

params:

  • module: the local filename of the lambda module to test (relative to the folder where moromi is being called from)
  • handler (default handler): the handler name exported by the lambda module
  • request: a request that the handler should be called with, with normalised headers
  • response (optional): a response event that the handler should be called with, with normalised headers

Example

Given the following lambda function:

module.exports.handler = ({ Records: [{ cf: { request: {
  uri, method = 'GET', querystring = '', headers
} } }] }, context, callback) => callback(null, {
  uri,
  method,
  headers
});

the following moromi test will pass:

{
  name: 'example aws lambda test',
  type: require('moromi-aws-lambda')
  params: {
    module: '../index.js',
    request: {
      uri: '/test',
      headers: { Host: 'example.is' }
    }
  },
  expected: {
    uri: '/test', method: 'GET',
   'headers.Host': 'example.is'
  }
}