This fixes an issue where using factory extension methods causes the sequences to diverge and be independent. Since the extension methods are the core building blocks for "traits", which are intended to provide syntax sugar for building objects, this behavior is unexpected.
An example of the problem:
class UserFactory extends Factory<User> {
admin() {
return this.params({ admin: true });
}
}
const userFactory = UserFactory.define({ sequence }) => {
return {
id: sequence,
admin: false,
};
});
userFactory.build().id // 1
userFactory.admin().build().id // 2 -- correct, picks up at same spot as userFactory
userFactory.build().id // 2 -- incorrect, since `admin()` generated a new factory that does not share sequence
This fixes an issue where using factory extension methods causes the
sequence
s to diverge and be independent. Since the extension methods are the core building blocks for "traits", which are intended to provide syntax sugar for building objects, this behavior is unexpected.An example of the problem:
Closes #49