Unit test & Angular

Tutorials on testing

A repository to an app with many testing case ordered by type https://github.com/juristr/angular-testing-recipes

In this article he explain 3 types of components testing :

  • isolated tests are a great way to test drive your components and test complex logic.

  • Shallow tests are isolated tests on steroids, and they should be used when writing a meaningful test requires to render a component’s template.

  • Integration tests verify that a group of components and services (e.g., the router) work together.

DebugElement vs fixture.debugElement

  • 2 Ways to access the DOM inside unit test in angular



Asynchronous problems

Mocking dependencies

Testing services

Overriding component : Testing component with child component


Testing ngrx

Debugging test

  • Console.log

  • open a chrome debugger in the karma launched chrome window a trick is that the error messages are something difficult to understand because of the fact that it refere to compile code transformed in ES5 like

    at Object.reducer (webpack:///./src/app/platform/applicability/store/reducers/applicability.reducer.ts?:104:73)


  • by opening the chrome debugger

  • going to