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: Standalone CVA component #3778

Closed
kekel87 opened this issue Oct 5, 2022 · 6 comments · Fixed by #3794
Closed

Bug: Standalone CVA component #3778

kekel87 opened this issue Oct 5, 2022 · 6 comments · Fixed by #3794
Assignees
Labels
bug Something isn't working released v14.2.4

Comments

@kekel87
Copy link

kekel87 commented Oct 5, 2022

Description of the bug

Hi 🙃, I was migrating most of my dumb components to Standalone.

But the tests of the ones implementing ControlValueAccessor won't start.

I've got this error:

TypeError: Cannot read properties of undefined (reading 'constructor')

I also tried with NgModel without success (see in example).

Thanks !

An example of the bug

Link: https://stackblitz.com/edit/github-gdvfn5?file=src%2Ftest.spec.ts

Expected vs actual behavior

That the CVA standelone component can be tested with ng-mocks.

@kekel87 kekel87 added the bug Something isn't working label Oct 5, 2022
@satanTime
Copy link
Member

Hi @kekel87,

thanks for the report. You need to keep NG_VALUE_ACCESSOR too for now.
I'll be working on a fix to automatically mark NG_VALUE_ACCESSOR as kept if it's possible.

The thing is that providers of StandaloneCVAComponent are replaced with mocks, but I think if the providers point to the same class, then it can stay as it is.

satanTime added a commit to satanTime/ng-mocks that referenced this issue Oct 9, 2022
satanTime added a commit to satanTime/ng-mocks that referenced this issue Oct 9, 2022
satanTime added a commit to satanTime/ng-mocks that referenced this issue Oct 9, 2022
satanTime added a commit that referenced this issue Oct 9, 2022
fix(core): providers with useExisting will be kept if their value is a kept declaration #3778
@satanTime
Copy link
Member

v14.2.4 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.

@kekel87
Copy link
Author

kekel87 commented Oct 10, 2022

Thank you very much for your reactivity. Have a good week.

@satanTime
Copy link
Member

You too! Stay in touch!

@LukasMachetanz
Copy link

LukasMachetanz commented Feb 27, 2023

@satanTime We are using version ^14.6.0 of ng-mocks and experience the same problem. Can you certainly confirm that this issue is resolved?

@satanTime
Copy link
Member

Hi @LukasMachetanz, could create a min example of the issue? Feel free to submit a new bug.

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.2.4
Projects
None yet
3 participants