r/angularjs • • Jan 27 '16

Free AngularJS Unit Testing Course

EDIT: The original promotion is over, but you can still get the full course for over 50% off using coupon code REDDIT10 on checkout or using the following link: https://www.udemy.com/unit-testing-angularjs/?couponCode=REDDIT10

Hey everyone, I just launched an AngularJS course on Udemy, covering Unit Testing with Karma, Jasmine and Istanbul.

The first few hundred people can enrol for free using coupon code NGTEST over here: https://www.udemy.com/unit-testing-angularjs/?couponCode=NGTEST

Feel free to ask me questions, and any feedback is appreciated :)

EDIT: The free launch promotion is now over, thanks to all those who enrolled!

53 Upvotes

21 comments sorted by

5

u/mattkentz Jan 27 '16

Thanks everyone for the great response, hope you enjoy it!

1

u/simonmales Jan 28 '16

I just did the whole course in two sittings.

I have experience with Angular, but very little with experience with testing so it was easy for me to keep up.

I did to course to get a deeper understanding about Jasmine specific methods, as it is a framework on its own.

I recommend it, and I would suggest to try and do the whole course in 1 to 3 sitting to get the most out if it.

PS: Lecture 17 has swearing in it :)

1

u/mattkentz Jan 28 '16

Thanks for the feedback Simon!

I checked out Lecture 17 and there were some...mistakes...so I've fixed and re-uploaded.

1

u/[deleted] Jan 28 '16

Do you cover e2e testing?

Do you take a tdd approach or write tests after?

3

u/mattkentz Jan 28 '16

E2E testing using Protractor is just mentioned, but I do not dive in to it. It might be something that I add on in the future, but for now the focus is on Unit Testing.

Regarding TDD, it's a mixed approach. I didn't write the tests before the actual code (in the traditional traffic light approach), but I wrote tests as I added features. So each lecture introduces a new features, and the test is written along with it.

2

u/eflat123 Jan 28 '16

Pluralsight, btw, has a decent intro to protractor.

Don't mean to take anything away from Matt or Udemy; the more good resources for devs, the better :-)

2

u/dulerakun Jan 27 '16

Thank you, will leave a full comment once I go through the course.

1

u/beeman_nl Jan 27 '16

Awesome, thanks a lot!

1

u/ReefJunkie Jan 27 '16

Thanks, just signed up.

1

u/estpla Jan 27 '16

Thanks!!

1

u/br0wnvetter Jan 27 '16

Thanks a lot!

1

u/deesax Jan 27 '16

Just signed up! Thanks so much!

1

u/[deleted] Jan 27 '16

Cool, thanks!

1

u/mv740 Jan 28 '16

Thanks

1

u/hpuser Jan 28 '16

Very cool! Thanks buddy!

1

u/Renegade-One Jan 28 '16

Thank you man! I have a coworker who loves unit testing, and I wanted to look into it but never had the time. Now, udemy ftw!! (Seriously, greatest freaking learning resource out there). Thanks again!!! :)

1

u/dmitri14_gmail_com Jan 28 '16 edited Jan 28 '16

Thanks for the nice tutorial and generosity to put it up for free. Some constructive critique to help make it better:

  • You should write your tests before not after the code.

  • Place your test files next to the code to be tested, rather than hiding them away in remote test/unit directory. This is how Angular Material does, as a good example: https://github.com/angular/material/tree/master/src/components/datepicker Also they don't use any preprocessors: https://github.com/angular/material/blob/master/config/karma.conf.js

  • In my opinion, you should try to avoid debugging as much as possible, using tests instead to catch all bugs. If you ever need to debug, it might be a sign that your functions are doing too much and need to be split into smaller ones with own tests.

  • It seems coverage is a default directory automatically created, so you don't need to configure it manually. This alone does it for me:

`

preprocessors: {
    'demo/**/*.js': 'coverage'
},

reporters: ['progress','coverage']

`

Angular-specific:

  • You should avoid over-using $scope in favour of Controller as syntax.

  • You should keep your controllers thin, abstracting your business logic into Services. It is the Services that should contain most of your tests.

  • According to more recent practices, you should ever avoid controllers whatsoever :-) Other than having them inside Components. This is what React and Angular 2 do, and you want to make your code structure resembling theirs, even in Angular 1.

  • You don't need to wrap you directive into angular.element: https://github.com/angular/material/blob/master/src/components/menuBar/menu-bar.spec.js#L169

  • I've heard that PhantomJS is not quite equivalent to real browsers. Testing in Chrome or browsers you want to support is more reliable, and might be just fast enough for your needs.