-
Notifications
You must be signed in to change notification settings - Fork 154
RFC: Testing Factories for AWS Data Objects #445
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
@heitorlessa it is worth thinking about this across both Python, Java and Typescript (aws-powertools/powertools-lambda-python#1169) |
Thanks for opening this issue @simonireilly. As a former AWS customer, I would like to say that this is something I wanted myself as well, back then. |
I've been using @serverless/event-mocks for this, there are a few others, all are out of date and not maintained. |
For Python is have a lot of mocks and sample events. So whichever solution we have in mind it would be great to has the potential for reuse across python, typescript, Java and .Net. |
If any ESM users are looking for an utility similar to what's being proposed here: I've been shipping my own set of test data factories for Lambda events, built using the same combo ( |
Hello, I discussed this with the team and we came to the conclusion that at lest for the time being, we are not positioned to help with this type of use case in the way we would feel confident doing so. Our position stems from the fact that even if we took the time to hand-roll data objects for each integration and variation of event that can trigger a Lambda function, we would not be able to detect changes to these interfaces on actual AWS resources. This is because as of today there's no centralized repository of such events, and we simply don't have capacity to deploy and maintain an environment with all these combinations deployed. Because of this, we won't be moving forward with this for the time being. We do however provide Zod schemas for some popular payloads for Lambda integrations, which you can use in conjunction with 3rd packages like this one to generate an approximation of event payload to test your function. We're also open to revisit the decision in the feature if circumstances change, but until then I'll close the issue as not planned. |
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. |
Description of the proposal
There should be a consistent way to produce test fixtures for AWS lambda environments
Name of the core utility (and consequently the folders that contain the libraries):
packages/factories
Justification
When it comes to making effective use of AWS in unit and integration testing, developers will create data objects which have the interfaces of the 'aws-lambda' types package.
This is true, even within this project;
These untyped objects become a cause for churn, and often because a single source of truth is not present, they can misdiagnose behaviors through simple omission of fields.
Goals
Proposed API
There is an example here that utilizes
faker
andfishery
to create type compliant factories that can be deep merged to allow for standard testing objects:Installation:
Usage
Consider the following test that is written in #364
This test becomes:
The text was updated successfully, but these errors were encountered: