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

Bug: MockBuilder.mock component that extends a service results in mock that's placed in providers rather than declarations #2646

Closed
DmitryEfimenko opened this issue Jun 2, 2022 · 6 comments · Fixed by #2650
Assignees
Labels
bug Something isn't working released v14.0.0

Comments

@DmitryEfimenko
Copy link

Description of the bug

Let's say we have a component that extends a service. Trying to call MockBuilder.mock(MyComponent).build() on that component results in the component mocked as a service and placed in the providers. Please see the repro link.
I suspect that similar behavior would be observed if we call .keep(...)

A repo with an example of the bug

Link: https://codesandbox.io/s/cool-swartz-f4nnwz?file=/src/test.spec.ts

Expected vs actual behavior

The mocked component should end up in declarations

@DmitryEfimenko DmitryEfimenko added the bug Something isn't working label Jun 2, 2022
@satanTime
Copy link
Member

Hi. Thanks for reporting the issue. I'll try to fix it today.

@satanTime
Copy link
Member

is it only Service -> Component in your projects, or you have other combinations?

@satanTime
Copy link
Member

satanTime commented Jun 2, 2022

Hi @DmitryEfimenko, could you check whether the fix works well on your project?
Package: ng-mocks.zip

@DmitryEfimenko
Copy link
Author

The issue with the component that extends a service is fixed. Thanks! However, I still am experiencing an issue where I have to explicitly import ReactiveFormsModule.
Here's repro: https://codesandbox.io/s/vibrant-tree-6ghgh8?file=/src/test.spec.ts (like described in #2647).
We can probably close this issue and re-open the other one... or just discuss it here. Up to you!

satanTime added a commit that referenced this issue Jun 3, 2022
fix(MockBuilder): respect extention of classes with different decorators #2646
@satanTime
Copy link
Member

I see. Good. I've reopened that one. Please try to find a way how I could reproduce it on my side.

@satanTime
Copy link
Member

v14.0.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released v14.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants