DEV Community

Cover image for How To Level Up Your Angular Unit Testing Game (3/3)

How To Level Up Your Angular Unit Testing Game (3/3)

Alisa on January 28, 2019

This is the third post in the series about Angular unit testing. If you are unfamiliar with using Angular CLI or making changes to Karma configurat...
Collapse
 
parthoshuvo profile image
Shuvojit Saha

Hi,

Thanks for sharing the testing series. It works on below Angular 7 particularly for "Create Custom Parameter". I went through your process in my Angular 7 app but it didn't work. Would you suggest how to use "custom command line parameter" testing in Angular 7?

Thanks.

Collapse
 
alisaduncan profile image
Alisa

Thanks Shuvojit!

You are correct, the custom parameter doesn't work for Angular v7. I started working on this while still on Angular v6 and waited too long before posting. I decided to post the custom parameter section anyway since some people may not be able to update their Angular version.

If you are able to figure out a way to submit custom parameters in Angular v7 or v8, please share. I'd love to hear about it.

Collapse
 
engrmubashir profile image
miq

Great articles, really loved the series :). I need your suggestion with my Angular unit test problem. I have a 'abc.service' which initializes a 'Secondary App' for a remote signup for account creation. When I run the tests it throws error 'Secondary App already exists'. But when I comment that initialization method, everything works fine. How can I solve this problem? I tried the following:

  1. Exclude that 'abc.service' in Karma.config (but does not seem to work)
  2. I am using fdescribe with spec files to run specific tests
  3. This seems an app compilation problem during test run (Karma finds two app initializations)

Please help me out, thanks a lot!

Collapse
 
alisaduncan profile image
Alisa

Hi there! I just saw your comment so hopefully this response isn't too late. Are you testing your 'abc.service' and it has a reference to another service? or something else?

Collapse
 
jenc profile image
Jen Chan

Thanks for writing this tutorial. Just got started looking into unit testing and this offered a really concise overview.

Collapse
 
alisaduncan profile image
Alisa

Thank you for your kind words!

Collapse
 
bijenderk82 profile image
Bijender

Thanks @alisa , this series is really helpful. You have covered almost all the important points required to start the testing. Appreciate your time and efforts

Collapse
 
alisaduncan profile image
Alisa

Thank you for your kind words!

Collapse
 
briancodes profile image
Brian • Edited

Really helpful series of articles. Will be adding 'html' to the coverage, and using the @shortcut/imports - some great testing tips here 👍

Collapse
 
alisaduncan profile image
Alisa

Thanks! I'm glad to hear it!