Socket
Socket
Sign inDemoInstall

@serverless/event-mocks

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/event-mocks

Event Mocks is a simple library designed to generate simple AWS events for testing and automation purposes.


Version published
Weekly downloads
884K
decreased by-5.52%
Maintainers
1
Weekly downloads
 
Created
Source

Event Mocks

A small library that includes details mocks of AWS Lambda event sources. Useful for use when unit testing your Lambda functions. Supported Event Sources are: SNS, API Gateway, S3, & Scheduled.

The library simply uses default event source mock templates and merge it with any overwrite you provide. Check out the JSON template files to learn more about the data structure of each event source.

Usage

SNS

const createEvent = require('aws-event-mocks');
const mocked = createEvent({
  template: 'aws:sns',
  merge: {
    Records: [{
      Sns: {
        Message: 'trigger-email'
      }
    }]
  }
});

API Gateway

const createEvent = require('aws-event-mocks');
const event = createEvent({
  template: 'aws:apiGateway',
  merge: {
    body: {
      first_name: 'Sam',
      last_name: 'Smith'
    }
  }
});

S3

const createEvent = require('aws-event-mocks');
const event = createEvent({
  template: 'aws:s3',
  merge: {
    Records: [{
      eventName: 'ObjectCreated:Put',
      s3: {
        bucket: {
          name: 'my-bucket-name'
        },
        object: {
          key: 'object-key'
        }
      }
    }]
  }
});

Scheduled

const createEvent = require('aws-event-mocks');
const event = createEvent({
  template: 'aws:scheduled',
  merge: {
    region: 'us-west-2'
  }
});

Kinesis

const createEvent = require('aws-event-mocks');
const event = createEvent({
  template: 'aws:kinesis',
  merge: {
    data: new Buffer('this is test data').toString('base64')
  }
});

FAQs

Package last updated on 17 Apr 2019

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