-
Notifications
You must be signed in to change notification settings - Fork 155
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
Comments
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 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. |
@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). |
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. |
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. |
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.
The text was updated successfully, but these errors were encountered: