
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
lambda-tester
Advanced tools
Simplifies writing unit tests for AWS Lambda functions using Node.js.
LAMBDA_TASK_ROOT
to the application's rootInstall via npm.
npm install lambda-tester --save-dev
Lambda handlers with support for callbacks use the typical Node.js asynchronous signature:
exports.handler = function( event, context, callback ) {
callback( null, 'success!' );
}
The following example shows a simple case for validating that the Lambda (handler) was called successfully (i.e. callback( null, result )
:
const LambdaTester = require( 'lambda-tester' );
const myHandler = require( '../index' ).handler;
describe( 'handler', function() {
it( 'test success', async function() {
await LambdaTester( myHandler )
.event( { name: 'Fred' } )
.expectResult();
});
});
If the handler calls callback( err )
, then the test will fail.
Additionally, if one wanted to test for failure, then the following code would be used:
const LambdaTester = require( 'lambda-tester' );
const myHandler = require( '../index' ).handler;
describe( 'handler', function() {
it( 'test failure', async function() {
await LambdaTester( myHandler )
.event( { name: 'Unknown' } )
.expectError();
});
});
Note: you must either return the LambdaTester
instance back to the testing
framework or use the await
/async
keywords.
Complete documentation can be found in our documentation page.
lambda-tester
We'd love to get feedback on how you're using lambda-tester and things we could add to make this tool better. Feel free to contact us at feedback@vandium.io
Starting with version 4.0, lambda-tester supports node versions 10 and higher. If you require support for older versions of node, then use a previous version of lambda-tester.
4.0.0 (2019-11-23)
Breaking:
Strict checking for how the results/errors are captured have been relaxed. this
can be re-enabled using the strict()
method after creating the LambdaTester
instance.
Node.js versions are no longer checked before running the tests.
New:
lambda-event-mock
)Updated:
expectResult()
and expectError()
are now the preferred methods to verify
the handler's execution. If strict mode is enabled, then it will enforce that
the callback is called.Internal:
FAQs
Unit/Integration tests for AWS Lambda handlers
The npm package lambda-tester receives a total of 26,403 weekly downloads. As such, lambda-tester popularity was classified as popular.
We found that lambda-tester demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.