how do i increase my coverage of jasmine?

  • you need to create a test case for each if statement and you need to provide each time a suitable feed from your service, so I suggest that you use spies instead of referencing you real FlagService
  • create a global fixture so you don’t have to instantiate it for every test case
  • You do not need to call .detectChanges since you already call ngOnInit.
    Please see the below project, that cover 100% your appComponent. (https://github.com/IsmailDiari/stackoverflow-anglar-jasmine-code-coverage).
    enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top