-
-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
First of all, thank you guys for your hard work, this is really cool lib!
During the integration with the fishery, we found one behavior that seems wrong.
Imagine that we have Users with Posts and I what to generate a list of users with random posts, let's say 5 users with 5 posts.
To make it more useful I've done it like this:
type Post = {
id: number;
}
type User = {
id: number;
posts: Post[];
};
const postFactory = Factory.define<Post>(({ sequence }) => ({ id: sequence }));
class UserFactory extends Factory<User> {
withPosts(posts?: Post[]){
return this.params({
posts: posts || postFactory.buildList(5),
})
}
}
const userFactory = UserFactory.define(({ sequence }) => {
return {
id: sequence,
posts: [],
};
});
const users = userFactory.withPosts().buildList(5);
So after I created a list of users I expected to have 25 different posts, but I have 5 users with the same 5 posts.
To Reproduce
butov-printifyallanvobraun
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working