JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 30701
  • Score
    100M100P100Q233419F
  • License MIT

This library returns a mock context object that can be used to test lambda functions.

Package Exports

  • aws-lambda-mock-context

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-lambda-mock-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

aws-lambda-mock-context

This library returns a mock context object that can be used to test lambda functions

Installation

npm install --save aws-lambda-mock-context

Usage

This library can be used with promises or callbacks.

// module dependencies
var context = require('aws-lambda-mock-context');

// Start the test
describe('Lambda Test', function() {
    
    it('Should call the succeed method', function(done) {
        index.handler({hello: 'world'}, context());
        
        context.Promise
            .then(function() {
                // succeed() called
                done();
            })
            .catch(function(err) {
                // fail() called
                done(err);
            });
    });
    
    it('Should call the fail method', function(done) {
        index.handler({hello: 'wrld'}, context(function(err, result) {
            if(err) {
                // If we have an error, it's fine
                done();   
            }
            else {
                // If we don't have an error, it means the fail() method was not called
                done(new Error('Fail not called');   
            }
        ));
    });
});

Contributors

License

MIT © Sam Verschueren