Test AWS Lambda handler built with javascript on the command line. This tool loads the javascript and call the handler function with the provided event data. Handler which can handler streaming are supported when using the flag
-s
.
Usage: pnpm dlx lambda-handler-tester [options]
Options:
-V, --version output the version number
--handler [PATH] path to request handler
-s, --streaming streaming handler (default: false)
-e, --event [PATH] path to an json file with a valid event
-c, --context [PATH] path to an json file with a valid context
-p, --path [PATH] path to request (default: "/")
--decode-base64 decode base64 body (default: false)
--header only show header without body (default: false)
-v, --verbose enables verbose logging (default: false)
--response-time measure the response time (default: false)
--repeat <number> repeat request [n] times (default: 1)
--profile-cpu profile JavaScript CPU usage to "aws-lambda-handler.cpuprofile" (default: false)
--silent no output (default: false)
-d, --debug enables verbose logging (default: false)
-h, --help display help for command
Examples:
$ pnpm dlx lambda-handler-tester
0.0.xx-development
These frameworks are detected:
If your network is not detected you will need to provide the path to the file with the AWS Lambda Handler:
$ pnpm dlx lambda-handler-tester --handler ./aws-lambda-output/handler.mjs
The option --response-time
together with the option --repeat <number>
allows to measure response time for first and repeated calls.
Report:
First run:
Name size min max median sum
---- ---- ---- ---- ------ ----
1 2.24 2.24 2.24 2.24
Repeat 100 times: 100%
Name size min max median sum
---- ---- ---- ---- ------ ----
100 0.02 0.75 0.02 4.78
Total running time: 5ms
The option --profile-cpu
allows to profile the CPU usage of the handler to the file aws-lambda-handler.cpuprofile
. The handler needs to be called from NodeJS with the --inspect
flag to generate the file or at least run in a VS Code JavaScript Debug Terminal.
Streaming handlers are not supported!