-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
RFC: Mocking #197
Comments
My thoughts on this topic:
|
I'm inclined to disagree. This would add maybe a kilobyte to the bundle size max. Plus I consider mocking is a pretty fundamental bit of functionality for a library that is trying to be the single-source of truth for type information. Pretty sure we could eliminate more than a kilobyte from the bundle by using the |
Based on the same building/bundling-related reasons from #264 (comment) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm open to a PR for a
.mock
method that lets you generate mock data for your schemas.Proposal
New base method:
.mock
A
.mock
method on the base class.Overrides
This method could accept some parameters that let you overriding the default mocking functions for each data type (e.g. strings, numbers, tuples, etc).
Instance-specific mocking functions
There would also need to be a way to override the mocking function for a particular schema instance (probably a
.mocker()
or.setMocker()
method on the base class).Issues
Refinements
Zod has no way of generating a value that satisfies a given refinement. There would also need to be a way to override the mocking function for a particular schema instance (probably a
.mocker()
or.setMocker()
method on the base class).Unions
Which union "option" should be used to generate the value? Perhaps a randomly chosen one? Should the mocked value for an optional value be
undefined
50% of the time?Transformers
Should Zod mock a value for the input or the output type? Not a huge issue, this can just be an option/flag in the
.mock
method.The text was updated successfully, but these errors were encountered: