{"id":19042510,"url":"https://github.com/serverless/event-mocks","last_synced_at":"2025-09-10T14:43:07.748Z","repository":{"id":44220270,"uuid":"181548992","full_name":"serverless/event-mocks","owner":"serverless","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-01T18:37:35.000Z","size":15774,"stargazers_count":73,"open_issues_count":19,"forks_count":15,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-09-03T04:38:26.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-15T19:03:52.000Z","updated_at":"2025-08-30T19:35:57.000Z","dependencies_parsed_at":"2024-11-08T22:38:51.036Z","dependency_job_id":"4b26b3a7-5153-4d74-8df1-8f4e8a3f2c3c","html_url":"https://github.com/serverless/event-mocks","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/serverless/event-mocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-mocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-mocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-mocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-mocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/event-mocks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-mocks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274411824,"owners_count":25280193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T22:38:03.840Z","updated_at":"2025-09-10T14:43:07.727Z","avatar_url":"https://github.com/serverless.png","language":"TypeScript","readme":"# Event Mocks\nA small library that includes details mocks of AWS Lambda event sources. Useful for use when unit testing your Lambda functions.\nSupported Event Sources are:\n- [x] API Gateway\n- [x] SNS\n- [x] SQS\n- [x] DynamoDB\n- [x] S3\n- [x] Scheduled\n- [x] Websocket\n- [x] Alexa Skill\n- [x] Alexa Smart Home\n- [x] CloudWatch\n- [x] CloudWatch Log\n- [x] Cognito Pool\n- [x] IoT\n\nThe library simply uses default event source mock templates and merge it with any overwrite you provide. [Check out the JSON template files](./lib/events/aws) to learn more about the data structure of each event source.\n\n## Usage\n\n### SNS\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst mocked = createEvent(\n  \"aws:sns\",\n  {\n    Records: [{\n      Sns: {\n        Message: \"trigger-email\"\n      }\n    }]\n  });\n```\n\n### API Gateway\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst event = createEvent(\n  \"aws:apiGateway\",\n  {\n    body: {\n      first_name: \"Sam\",\n      last_name: \"Smith\"\n    }\n  });\n```\n\n### S3\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst event = createEvent(\n  \"aws:s3\",\n  {\n    Records: [{\n      eventName: \"ObjectCreated:Put\",\n      s3: {\n        bucket: {\n          name: \"my-bucket-name\"\n        },\n        object: {\n          key: \"object-key\"\n        }\n      }\n    }]\n  });\n```\n\n### Scheduled\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst event = createEvent(\n  \"aws:scheduled\",\n  {\n    region: \"us-west-2\"\n  });\n```\n\n### Kinesis\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst event = createEvent(\n  \"aws:kinesis\",\n  {\n    data: new Buffer(\"this is test data\").toString(\"base64\")\n  });\n```\n\n### Dynamo\n\n```js\nimport createEvent from \"@serverless/event-mocks\"\n\nconst event = createEvent(\n  \"aws:dynamo\",\n  {\n    Records: [\n      {\n      eventID: \"1\",\n      eventVersion: \"1.0\",\n      dynamodb: {\n        Keys: {\n          Id: {\n            N: \"101\"\n          }\n        },\n        NewImage: {\n          Message: {\n            S: \"New item!\"\n          },\n          Id: {\n            N: \"101\"\n          }\n        },\n        StreamViewType: \"NEW_AND_OLD_IMAGES\",\n        SequenceNumber: \"111\",\n        SizeBytes: 26\n      },\n      awsRegion: \"us-west-2\",\n      eventName: \"INSERT\",\n      eventSourceARN: \"arn:aws:dynamodb:us-east-1:123456789012:table/images\",\n      eventSource: \"aws:dynamodb\"\n      }\n    ]\n  });\n```\n\n### Websocket event\n\n```js\n  const event = createEvent(\"aws:websocket\", {\n    body: {\n      first_name: \"Sam\",\n      last_name: \"Smith\",\n    },\n    requestContext: {\n      connectedAt: 123,\n      connectionId: \"abc123\",\n    },\n  });\n```\n### CloudWatch event\n\n```js\n  const event = createEvent(\"aws:cloudWatch\", {\n    \"detail-type\": \"Something has been deleted.\",\n    \"region\": \"us-east-1\"\n  });\n```\n\n### CloudWatchLog event\n\n```js\n  const event = createEvent(\"aws:cloudWatchLog\", {\n    awslogs: {\n      data: \"Some gzipped, then base64 encoded data\",\n    }\n  });\n```\n\n### Alexa Skill event\n\n```js\n  const event = createEvent(\"aws:alexaSkill\", {\n    request: {\n      type: \"CanFulfillIntentRequest\",\n    },\n    context: {\n      System: {\n        device: {\n          deviceId: \"myDevice\",\n        },\n      },\n    },\n  }\n```\n\n### Alexa SmartHome event\n```js\n  const event = createEvent(\"aws:alexaSmartHome\", {\n    payload: {\n      switchControlAction: \"TURN_OFF\",\n    },\n  }\n```\n\n### IoT event\n```js\n  const event = createEvent(\"aws:iot\", {\n    this: {\n      can: {\n        be: \"anything I want\",\n      },\n    }\n```\n\n### Cognito Pool Event\n```js\n  const event = createEvent(\"aws:cognitoUserPool\", {\n    userName: \"Aaron Stuyvenberg\",\n  }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fevent-mocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fevent-mocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fevent-mocks/lists"}