npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aws-lambda-stubs

v0.3.3

Published

Providing stubs for all AWS Lambda invocation types for easy unit testing

Readme

AWS Lambda Stubs

Gone are the days you need to write stubs to unit test your AWS Lambda functions locally. This repository provides simple stubs for AWS Lambda services, allowing you to focus on writing and testing your Lambda functions without the overhead of continuously writing the same boilerplate stubs.

This is highly inspired by @types/aws-lambda that already provides the type definitions for AWS Lambda events and context.

There is support for all the typed AWS Lambda events defined in @types/aws-lambda and will be continuously updated as new event types are added. Each event that exists in @types/aws-lambda will have a corresponding stub function that is named by appending Stub to the event name. For example, for the SQSEvent type, there will be a SQSEventStub function that generates a stubbed SQS event object.

Installation

You can install the package via npm:

npm install --save-dev aws-lambda-stubs

Usage

Here's a simple example of how to use the stubs in your unit tests, given that handler is a Lambda function you want to test:

import { SQSEventStub } from "aws-lambda-stubs";
import { describe, expect, it } from "vitest";
import { handler } from "../src/sqs";

describe("sqs handler", () => {
  it("should log the received event", async () => {
    const mockEvent = SQSEventStub([
      {
        body: { message: "Hello, World!" },
      }
    ]);

    expect(handler(mockEvent)).toEqual({});
  });
});

The content of mockEvent will be:

{
  "Records": [
    {
      "messageId": "1",
      "receiptHandle": "MessageReceiptHandle",
      "body": "{\"key\":\"value\"}",
      "attributes": {
        "ApproximateReceiveCount": "1",
        "SentTimestamp": "1523232000000",
        "SenderId": "123456789012",
        "ApproximateFirstReceiveTimestamp": "1523232000001"
      },
      "messageAttributes": {},
      "md5OfBody": "a7353f7cddce808de0032747a0b7be50",
      "eventSource": "aws:sqs",
      "eventSourceARN": "arn:aws:sqs:us-east-1:012345678901:queue-name",
      "awsRegion": "us-east-1"
    }
  ]
}

As you can see, the stub provides a valid SQS event object that can be used to test your Lambda function locally. Saving you the trouble of having to create these objects manually.

Using the stubs will provide you valid AWS Lambda event objects, that are type-safe and in-sync with the actual AWS Lambda event definitions and typescript types from @types/aws-lambda.

[!IMPORTANT] Always customize the stub data to match your specific test cases. The stubs provide default values, but you should modify them to reflect the scenarios you want to test. Especially ensure that if you are checking against specific values in your tests, the stub data should match those values accordingly to avoid test failures if the default stubs change.

Contributing

Contributions are welcome! If you have suggestions for new stubs or improvements to existing ones, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.