0.0.3 • Published 4 years ago
moromi-aws-lambda-edge v0.0.3
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'
}
}