We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Testable Angular Forms | Martine Dowden | ng-conf 2022
Test and debug Angular forms effectively with Martine Dowden's expert tips, covering regex, accessibility, testing strategies, and best practices for form control manipulation.
- Make sure to test accessibility by using tools like Lighthouse and running it in different browsers and modes.
- Use regex carefully and understand what it’s doing, as it can be complex and hard to debug.
- Make sure to test for different types of invalid input and different error messages.
- Keep in mind that testing for accessibility is a process that requires careful consideration and iteration.
- Use a combination of automated and manual testing to ensure that your forms are accessible.
- Be cautious when using IDs in forms, as they can be brittle and prone to breaking if the underlying HTML structure changes.
- Use fixture.debug element to simplify testing and avoid having to manually create a debug element.
-
Use the
patch
function to manipulate form controls and test their behavior. - Test for different types of invalid input and different error messages.
-
Use
detectChanges
to trigger a change detection cycle and test the behavior of the form control. - Keep in mind that testing is an iterative process that requires careful consideration and iteration.
- Be careful not to over-architect your tests and make them too complex to maintain.
- Use a combination of testing libraries and frameworks to simplify testing and make it more efficient.
- Test for different scenarios and edge cases to ensure that your forms are working correctly.
-
Use the
throw
function to test for errors and ensure that the form control is handling them correctly. - Be mindful of the importance of accessibility and make sure to test for it thoroughly.
- Test for different types of invalid input and different error messages.
- Keep in mind that testing is an important part of the development process and should not be overlooked.