Component Test harnesses is a new feature introduced in angular 9. It is known to provide a legible and better API surface, which helps in the testing of Angular Materials. It gives the developers a proper way to interact with Angular Material components during the testing phase.

The APIs can interact with the components in a similar way to the end-users, and the tests can insulate themselves from the changes in the DOCUMENT OBJECT MODEL. This Angular version has introduced harnesses for all of the components. This makes testing a lot of more-easier for the developers. With the latest updates and harnesses for all components, developers can now create better test suites. Besides this phenomenal feature, performance improvements have also been included, and the API itself has improved significantly.

The parallel function can now be used to work with asynchronous actions in the tests in an easier manner as it allows the developers to run multiple asynchronous interactions with the components. This allows developers to perform multiple actions simultaneously which saves a lot of time. This function also takes care of change detection.

The Manual Change Detection function can be used to control the change detection in a more precise or fine manner by disabling automatic change detection in unit tests. This can help verify the more complicated scenarios. The official doc states that the test harnesses will run Angular’s change detection prior to reading the state of a DOCUMENT OBJECT MODEL element and after interacting with one.

Component test harnesses will provide helper methods to interact with the component under test as well as finding a specific component this makes the work of developers easier in many ways. This kind of development feature is useful in the near future. This feature personally made my coding easier with best practices being followed, and hope it might get some improvements.

references

https://material.angular.io/cdk/test-harnesses/overview

https://angular.io/docs