Skip to content

Feature request: Testing payload helpers #3883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
codyfrisch opened this issue May 1, 2025 · 4 comments
Closed
2 tasks done

Feature request: Testing payload helpers #3883

codyfrisch opened this issue May 1, 2025 · 4 comments
Labels
duplicate This issue is a duplicate of an existing one feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility rejected This is something we will not be working on. At least, not in the measurable future

Comments

@codyfrisch
Copy link

Use case

Currently to test lambdas with actual payloads we either have to run them locally, or generate payloads with AWS SAM and modify them for our needs. This can be cumbersome for testing and generating the expected payload for testing.

Solution/User Experience

Create a library which generates payloads with parameters for body, attributes, headers, and whatnot where appropriate (and helper functions to simplify them where needed).

This way we can dynamically generate payloads at runtime, and simplify test creation.

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@codyfrisch codyfrisch added feature-request This item refers to a feature request for an existing or new utility triage This item has not been triaged by a maintainer, please wait labels May 1, 2025
@dreamorosi
Copy link
Contributor

Hi @codyfrisch, thank you for opening this issue.

We had a similar feature request in the past (#445) that we didn't push through with because of competing priorities and the lack of confidence around the correctness of these events.

With that said, we now have Zod schemas for most events integrating with AWS Lambda, so it's relatively easy for customers to generate mock events using tools like @anatine/zod-mock - i.e.

import { APIGatewayProxyEventSchema } from '@aws-lambda-powertools/parser/schemas/api-gateway'
import { generateMock } from '@anatine/zod-mock';

const mockData = generateMock(APIGatewayProxyEventSchema);

Before continuing with the discussion, could you maybe share a code example of what you had in mind in terms of experience? It doesn't have to be 100% correct or working, something in between pseudo code and a code snippet will work.

@codyfrisch
Copy link
Author

@dreamorosi you're right, I totally spaced the libraries that generate mock data from Zod schemas as an option here.

You can close this out. That said, there may be value in the events in the parser's tests being made available for us to import. My main need is getting payloads that would pass through the parser schemas successfully (I really only care about the body but can't test envelopes otherwise). I thought maybe having a utility around those sample events to make it easy to access them, possibly to supply a body object for the test (that gets stringified into the returned object).

Copy link
Contributor

github-actions bot commented May 2, 2025

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2025
@dreamorosi dreamorosi moved this from Coming soon to Closed in Powertools for AWS Lambda (TypeScript) May 2, 2025
Copy link
Contributor

github-actions bot commented May 2, 2025

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi added duplicate This issue is a duplicate of an existing one rejected This is something we will not be working on. At least, not in the measurable future parser This item relates to the Parser Utility and removed triage This item has not been triaged by a maintainer, please wait labels May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue is a duplicate of an existing one feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility rejected This is something we will not be working on. At least, not in the measurable future
Projects
Development

No branches or pull requests

2 participants