Skip to content
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

feat: added static generation mocks #38

Closed

Conversation

Artem-Nanavov
Copy link

@Artem-Nanavov Artem-Nanavov commented Nov 19, 2023

Hello everybody. So, here what I did. ; )

What?
Added an option for generating static mocks.

Why?
Firstly, we have an issue for this. ))

Some people can you this lib for generate mocks (prefer static) and use it for visual regression test, right now we can't give this option, but this PR fix this problem.

If you want to generate static mock - just add --static flag into command and run.

How?

  1. Added CLI option in the cli.ts.
  2. Added condition into function, which is generating mocks. If we want static - we will return value, if we don't want - we return string with dynamic mock (I didn't change it, only added option for static).

P.S.
If you know how to make it more simple, comment below. ))

@zoubingwu
Copy link
Owner

I think this can be done with a much simpler solution, after calling transformJSONSchemaToFakerCode, we can put it in a new Function and run it once so it get a static data, I've already implemented it and will create another pull request soon

@zoubingwu
Copy link
Owner

@Artem-Nanavov pls check this out #43

@Artem-Nanavov
Copy link
Author

@zoubingwu I checked, your solution's better than mine. I'm closing my MR. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants