-
Notifications
You must be signed in to change notification settings - Fork 5
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
bug: avoid circular mocks #65
Comments
Is it any solution to resolve the circular dependency issue? |
Can you please give an example here? I'm working on a fix |
@omermorad The case when the circular dependency issue is absent: The case when the circular dependency issue is present: |
@DmitriyNikolenko, this requires a quite large change - moving into version 3.0.0 which will be released soon(!), in order to prevent this kind of scenarios. It will use the same mechanism as TypeORM and ClassValidator/ClassTransformer: export class User {
@Mock()
name: string;
// Using a callback here instead of putting the class explicitly
@Mock(() => Product)
product: Product;
} I will let you know as soon as we finish 🙏🏻 |
@DmitriyNikolenko, now that I'm diving into your example, it looks like you are creating an infinite loop: export class Product {
@Mock()
title: string;
@Mock(User)
user: User;
} export class User {
@Mock()
name: string;
@Mock(Product)
product: Product;
} Think about it, what result would you expect from this kind of fixture? |
@omermorad I expect to avoid war with this error in the project :) (https://ibb.co/sR7dVZK) Because TypeORM decorators line OneToMany, class-transformer decorators like Type and nestjs/swagger decorators like ApiProperty allows me to annotate cross types, but when I add mockingbird the app can crash on the build stage. It makes me sad because I am really excited about your library and I was going to keep on using it. |
@DmitriyNikolenko I understand the nature of cross-types, but I think it's different in Mockingbird; What I meant to ask is for an example of the end-result of the fixture. Let's take {
name: 'AwesomeUser',
product: {
title: 'Some Product'
user: // Whats gonna be here?
}
} The only solution I can think of is to indicate of many "iterations" you want until you stop filling those fixtures |
Maybe it's worth setting up a configuration of |
Hi @omermorad We are using your library and currently having lots of issues due to nesting problems. I have seen in the conversation that you are planning to release the fix in version 3.0. Is there any timeline you have in mind for the version release with this fix? Thanks for your effort and great work :) |
Hi @arvindsedha! I'm sorry to hear! We don't want any problems with the library of course, and we are working on a fix ASAP, it's going to be released in the next two weeks for sure! Can you share the use cases you have problems with? And how would you expect it to work from your side? I guess you mean: class Bird {
@Mock('Absolute Name')
name: string;
@Mock(() => Bird)
bird: Bird;
} ? |
Yes I mean the problem @DmitriyNikolenko mentioned. Great to hear that fix is soon on the way :) Keep up the great work! |
Hi @omermorad What's the situation of the release with this bug fix? When it is expected to be shipped? Regards |
Yo @arvindsedha, I tried to get an idea from you guys about how would you expect this kind of situation to behave; We both understand that generated mocks cannot be infinite, look at my previous replay: #65 (comment) If you can tell me more about the solution you are expecting to get, it will be very easy for me to manage a discussion about it and to understand what's the best solution in terms of refactoring and immediate fix. |
Hi @omermorad Thanks. @DmitriyNikolenko would you please answer or explain how it should work? Regards |
I expect behaviour like class-transformer does |
@DmitriyNikolenko
So you expect it to be ignored? |
Expected behavior stems from real-world use cases. Otherwise, when I'm going to create an array of permissions they should have user created for each permission but without references back. It's my opinion. |
@DmitriyNikolenko makes sense. @arvindsedha this kind of idea gives you a solution as well? |
@omermorad yes. @DmitriyNikolenko knows this area well! Thanks @DmitriyNikolenko |
No description provided.
The text was updated successfully, but these errors were encountered: