-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Reactive form testing won't validate the form correctly #48
Comments
Just faced the same issue today after debugging it for an hour... I noticed that (in tests) @NetanelBasal @danzrou do you have any idea from where should I look at to propose a fix? Or do you guys plan to fix it by yourself? |
@yackinn, can you create a reproduction on stackblitz, please? |
@rafaelss95 @yackinn - did you test it on latest version? |
@NetanelBasal @danzrou I've setup a NX project with Jest to demonstrate the issue here: https://github.com/rafaelss95/reactive-forms-48. You can see that the tests will fail when you import PS: If you put a |
I honestly don't know what we're missing here.
No errors. |
Have you tested it using the repo I provided above? I literally copied your example and it doesn't seem to work there either.
I mentioned expect(formGroup.get('password').errors).toEqual({ required: true });
expect(formGroup.get('username').errors).toEqual({ required: true });
expect(formGroup.get('password').validator).toBeDefined();
expect(formGroup.get('username').validator).toBeDefined(); All of them fail. It only works if you use PS: I don't know if that matters, but in the repo I provided, I use |
Well, we're testing with Jest as well - this is the test I just ran and it passed with no errors :(
The difference that I am testing without any component, but that should not interfere in any way. |
That's really strange 🤔.
Thanks 🙏. |
Hey @danzrou, did you have any time to check it out? Please, let me know of any news. |
Hey, I actually did. |
Hey guys, we are facing this same issue, we have a nx repo with jest where we been using ngneat/[email protected] for some time, and yesterday we tried to migrate to 1.7.0 and notice a bunch of test failing, I copied and pasted the simple test @rafaelss95 posted and they fail the same way, and manual testing of the app running showed the validation behaving fine so is only the test, we did discover something we downgraded versions to see with on which one the test pass and the did with 1.3.0, 1.3.1 makes them fail again, this is happening with @nrwl/[email protected] and [email protected] and ts 4.1.2, jest 26.2.2, I went through the commits between 1.3.0 and 1.3.1, and did not notice anything that could have caused this |
I'm submitting a...
Current behavior
When testing a simple component that has a setup form method on init the test for an invalid form fails. The form is valid without having values.
Swapping the ngneat form builder for the Agnualr form builder from angular core it works fine.
The test will output the form's invalid property as true.
Logging the output in the browser works as expected.
Jest is used as a test runner
Expected behavior
The test should output an invalid form after setup.
Minimal reproduction of the problem with instructions
Environment
The text was updated successfully, but these errors were encountered: