Testing Angular 2+ Apps with Jasmine and Karma

A step-by-step and pragmatic introduction to unit testing Angular2 apps.

Get the COMPLETE unit testing course here:

01:11 Introduction to Automated Testing
08:38 Different Types of Tests
14:40 Fundamentals of Unit Testing with Jasmine
22:24 Testing Strings and Arrays

This video is part of my Udemy course “Testing Angular Apps”. You can get the complete course with a discount here:

You can find all my courses here:

Stay in touch:






28 responses to “Testing Angular 2+ Apps with Jasmine and Karma”

  1. Marek Bystrzewski Avatar

    Man, a very good tutorial !

  2. Diego Melo Avatar

    very grateful for this content, you've convinced me =)

  3. Julie Larson Avatar

    Ugh, too much TDD sales pitch – get to the point plz

  4. kamalnadh k Avatar

    Wonderful tutorial. I got the detail understanding of testing within an hour. Thank you for this tutorial

  5. Gleb Dianov Avatar

    Hi Mosh, can you get straight to the point instead of talking about random shit for a lot of time before starting explaining the actual stuff.

  6. Anup Baghel Avatar

    Thanks Mosh its very helpfull and crystal clear , it my first point to understand testing in angular and I am clear 馃槈

  7. Jeremy Flowers Avatar

    Hi Mosh: I'm intrigued to know how you can get spec.ts files to appear in Chrome console, so you can put breakpoints on it. Per the Angular documentation here: https://angular.io/guide/testing#test-debugging Step 5 with CMD-P doesn't enable me to select file. Is there some sort of tweak you can do to karma.conf.js to allow this. All I see is something via polyfillls in Chrome 59 on a Mac with Sierra 10.12.5 when a test fails. That's not as intuitive as the original spec.ts source. I'm using Karma 1.7 and basically setup a project with ng new then merged it into the Tour of Heroes part 6 zip. Actually they have a zip file that enables the characterstics https://angular.io/generated/zips/testing/1st-specs.testing.zip It's a shame Angular guys didn't do a video talking through the config. There's a lot to it..

  8. Parth Makwana Avatar

    In development process, developers follows MVC Framework structure so In Automation,is it possible to follow the same and if yes then in automation what should be take under M,V & C?

  9. Shahzad Farukh Avatar

    It's an excellent tutorial. I am really glad to find it.

  10. Jose Mendez Avatar

    Hi Mosh, I am taking your course in Udemy, however I could not find the zip file with the code to test, please help!

  11. Crist贸bal Belda Avatar

    What about using PhantomJS instead of Chrome for testing?

  12. Shimi Tapiero Avatar

    Great video, Nicely explained

  13. Jung Sanghoon Avatar

    HI Mosh, Where is the zip file

  14. soroush shirali Avatar

    I have a question. Do we really need to write unit tests along with integrated tests? It seems that the way you defined integrated test it could cover all unit tests issues.

  15. soroush shirali Avatar

    Hi Mosh,
    I just wanted to suggest you to make a tutorial on using WWF within a real application in ASP.net MVC framework. There are many introduction videos to WWF but nobody has dived into the nitty-gritty of WWF or used it practically to implement a work flow in a web application.

  16. Ewald Cloete Avatar

    Hi Mosh!

    Probably an odd question, but how do you auto import your functions at the top? Is there a keyboard shortcut for VSC to do this?

  17. Hanna Seithe Avatar

    Hey Mosh,
    I was waiting for your answer to the question whether to Test first or to write Production Code first. Did I miss it? Would be curious what your thoughts are on that.

  18. RiderSagar Avatar

    Great intro to Jasmine and Karma. Thanks.

  19. Haroon Khan Avatar

    where is the code mosh?

  20. asha biradar Avatar

    Hi mosh. How to get the spec results on karma debug runner browser instead of console?

  21. Muna Padhy Avatar

    Hi mosh could you please share the source code?

  22. chauhan bharat Avatar

    very good tutorials

  23. James Cleary Avatar

    Verrryyyyyy gooood

  24. Ezequiel Zacca Avatar

    i am waiting for the second part! Great tutorial!

  25. Mihai Andrei Stanimir Avatar

    Nice tutorial.
    Regarding the test labelled "should increment the input if it is positive", this is a great description for a spec, but it does not precisely describe the test case. Imagine "should increment the input if it is positive" passes, but compute(3) returns 2. Imagine the minds inclined to believe that tests aren't useful; good luck convincing them otherwise after this happens.

  26. Yassine Msiah Avatar

    I Have Been Learning AngularJs 1 And I Wanna Know When To Know Im' Good Enough To To start learning Another Javascript Framework Or Library ?

Leave a Reply

Your email address will not be published. Required fields are marked *