Nomenclature Predictably Misunderstood

    aws-event-mocks

    0.0.0 • Public • Published

    AWS 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')
      }
    });

    Install

    npm i aws-event-mocks

    DownloadsWeekly Downloads

    4,204

    Version

    0.0.0

    License

    MIT

    Unpacked Size

    16.6 kB

    Total Files

    13

    Last publish

    Collaborators

    • hn2007