-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
.keep(ReactiveFormsModule) causes FormBuilder to malfunction #377
Comments
Hi, thanks for the report. Yep. Sorry. My bad. I implemented some wrong changes around 11.2.6. Could update to the latest version of ng-mocks? It shouldn't have the issue. |
Ah okay. You mean Angular itself. Then I'll dig into the issue next days and try to provide a fix ASAP. |
For now, I would say, that Angular fixed the issue they had. In a mock component, the A mix of mock components and real Might you describe, why you need to keep |
I do not want to mock either of them, You are right saying that the Angular test fails because form is undefined, the problem is it should be defined. form = this.fb.group({
name: [],
}); Here, |
Yep Good, then I'll dig into it later today / tomorrow. |
Hi, found the issue. The fix will take one week more. A workaround is to keep Sorry for the delay. |
This is the change: angular/angular@b93fb79, angular/angular#41126
I'll cover it on the next weekend. |
Hi @garrappachc, could you confirm that the new version works well for you? The package: ng-mocks.zip |
It works like a charm :) |
fix(#377): respect of providedIn in Injectable
v11.10.1 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. |
Hi, I'm in the process of updating our repo to Angular 15 with ng-mocks 14.6.0 and I got the same error as described above. Previously we just added |
Hi @Simon-Hayden-iteratec, right, this came from Angular updates. They started to make all module providers root providers to have better visibility in tree-shaking, because of that I've covered that in FAQ: https://ng-mocks.sudo.eu/troubleshooting/faq#error-ng01052-formgroup-expects-a-formgroup-instance-please-pass-one-in My recommendation is to add |
Ah, thanks a lot! Sorry for not finding the FAQ :) |
Let's say I have a decently simple component that uses the
FormBuilder
:When I test it with ngMocks, like that:
the injected
FormBuilder
instance spits out undefined value, causing angular to fail the unit test:This error is thrown because the value of
form
is undefined.I have uploaded a sample repo that reproduces this error: https://github.com/garrappachc/ng-mocks-reactive-forms-bug
In
form.component.spec.ts
you can see two unit tests - one that works (without using ngMocks) and one that doesn't.Also, I am not sure when was this error introduced, all I know is that Angular version 11.2.5 was working fine and 11.2.6 started to cause the issue - but Angular itself is fine.
Here's my Angular version bump pr that started failing: tf2pickup-org/client#803
The text was updated successfully, but these errors were encountered: