thoughtbot/fishery

Guidance on Production Use?

timfenney opened this issue · 2 comments

Thanks for contributing Fishery to the world!
How production-ready is this library? I don't get a lot of confidence from the description in package.json ("A library for setting up JavaScript factories to help build objects as test data, with full TypeScript support") and the docs that it is for much more than testing.
I'm using typeorm in a project, and right now the factory functions which create entity instances in front end code are kind of ad hoc, and this would seem to fill that role nicely.
I also use some custom TS code to type Entities based on which associated Entities were loaded with them, so it sounds like maybe I should wait to see what this more dynamic rewrite will bring.

Can't speak for other people, but I would definitely not be using this for production. There's definitely something to be said about using tools in the way they're intended being a much easier path in the long term. Factory functions in production make a lot more sense because they expose a lot less API surface area, so they're much more testable and debuggable.

This library makes it convenient to quickly build objects when you don't necessarily need to care about the details of all of the properties on the object. Tests are a great example of this and the primary use-case in mind. Other examples would include setting up data for a component library or prototyping, or maybe even seeding a testing database.

For your actual app code, I'd probably lean on writing your own custom builders/factories for your use-cases instead of using this library. I'm not saying the library wouldn't work, but it doesn't seem like the best approach, and like @casey-chow mentioned, it makes sense to use tools the way they were intended to be used.