Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render and test UI components Individually in angular 6

I'm building Angular 6 project and I need to test the appearance of angular component without assigning router link and manually loading it. I need to view individual component and how it behave. I don't have much understanding in unit tests in angular. How can I achieve this?

like image 252
Lakindu Akash Avatar asked Mar 07 '26 02:03

Lakindu Akash


1 Answers

There is a spec file associated with each component file (usually generated if you generate component using command ng g component new). This spec file supports unit testing. You need not load entire app to perform unit testing certain component.

If you go through the official tutorial, you will understand how unit testing works.

Note : When you run entire unit test cases, each spec file will execute independently, which means each file has its own configuration required to support unit testing of associated component

like image 103
Amit Chigadani Avatar answered Mar 08 '26 19:03

Amit Chigadani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!