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: allows creation of factory with specific adapter #28

Merged
merged 2 commits into from
Dec 10, 2023

Conversation

thiagomini
Copy link
Owner

Often times in a large codebase we might need to create factories for different ORM's. For those scenarios, it's useful to be able to provide a custom adapter per factory. This PR allows the user to provide a custom adapter as the third argument to FactoryGirl.define:

const userFactory = FactoryGirl.define(
        plainObject<User>(),
        () => {
          return {
            name: 'John Doe',
            email: '',
          };
        },
        new CustomAdapter(),
);

@thiagomini thiagomini added enhancement New feature or request feature labels Dec 10, 2023
@thiagomini thiagomini self-assigned this Dec 10, 2023
@@ -649,19 +649,6 @@ describe('Factory', () => {
});
});

it('extends the factory with new attributes', async () => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because this is not a valid usage anymore. We shouldn't be able to define properties in the factory that are not present in the model

@thiagomini thiagomini merged commit 5e5f0ce into main Dec 10, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant