Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-lambda-mock-context

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-lambda-mock-context

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

  • 0.2.0
  • npm
  • Socket score

Version published
Weekly downloads
16K
increased by14.46%
Maintainers
1
Weekly downloads
 
Created
Source

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

  • Sam Verschueren [sam.verschueren@gmail.com]

License

MIT © Sam Verschueren

Keywords

FAQs

Package last updated on 13 Aug 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc