Testing Dumb Components in Angular
Netanel Basal
1506

We can make the same test cases on the class, without the overhead of Angular artifacts.

From my perspective, tests like these are verifying your template. If you knew that your template was flawless, then you would just be testing (and documenting) Angular directives and pipes.

However, it is still important to verify that the template is written correctly, just like a static analyzer will do for your TypeScript code. Today, we have tools like the Angular language service that statically analyzes your templates.

If we wish to verify that the intent of the template is correct, we will do these tests or Selenium-based end-to-end tests with tools like Protractor where we have a complete browser environment.

My point is that these tests implicitly tests the same things as tests without the template would do. Nonetheless, they are more difficult to set up and reason about and they take longer to run, so it is a matter of priority. How important is it to verify the templates vs. only the logic? The same goes for end-to-end test, of course.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.