DEV Community

Cover image for ts-faker - Generating fake data using TypeScript interfaces
Sirwan Afifi
Sirwan Afifi

Posted on

ts-faker - Generating fake data using TypeScript interfaces

I recently built a Next.js website that generates fake data. Regularly, I perform routine tasks like this. Rather than manually go through the process, I decided to automate it. You just need to define your schema as TypeScript interfaces, and the test data will be generated automatically. I thought it would be a good idea to share the source code with you so that you can learn something from it. I hope you enjoy it.

source: https://github.com/SirwanAfifi/ts-faker
website: https://ts-faker.vercel.app/

Top comments (3)

Collapse
 
shrihari profile image
Shrihari Mohan • Edited

This Looks so interesting , Let me know if you are looking for collaborators, I just started using this for past 2 weeks to generate dummy data! Looking to improve the site UI wise and more features.

Collapse
 
raulinlee profile image
Lee Raulin

Pretty cool proof of concept, but for it to be useful for me, it would need to be able to handle interfaces composed of other interfaces. Even if I provide all the interfaces in a valid TS file, it just treats each one separately, creating data for them all, which I don't need, and treating interface types as strings, which means I'd to manually paste in data for nested interfaces, which sort of defeats the point.

Collapse
 
ingokodba profile image
Ingo Kodba

Yes, that is exacly what is missing. It needs to work on interfaces with all kinds of types, and fake data that generates should be of type that variable name implicates. Currently intermock module is the closest to that kind of thing, but it doesn't work between multiple files. Otherwise, nice work.