Angular Tips

Join us in our way to learning Angular.js

Introduction to Unit Test: Conclusions

| Comments

So we finished this unit test series. How do you feel? Are you going to try unit testing yourself?

I understand that testing can be daunting at first, but give it a try! You can always ask if you get stuck (on the IRC or SO).

There are much more stuff about testing but now that we done this series, I want to write separate articles on smaller subjects until I cover all I know about unit testing.

Cheers and try yourself!

Introduction to Unit Test: Directives

| Comments

Time for the last piece of unit testing, directives.

Directives sounds like a hard piece to test but actually is not bad at all. Of course a big and complex directive is more harder to test but if we stick to TDD, we won’t have any problem.

Introduction to Unit Test: Services

| Comments

Testing a service is not much more difficult than testing a filter, in fact, the same rules applies. The difficulty comes on what you do with your service. It is not the same thing testing a service that holds data (a wizard for example) than a service that does RESTful stuff + cache. I plan to write more testing examples on the future but for this article we are going to set the basics :)

Json Web Tokens: Examples

| Comments

So you liked my article about JWT and you want to see some examples right?

I have you covered with two basic but functional implementations of it both in Sails and Rails which you can adapt to you own framework of choice without hassle.

Json Web Tokens: Introduction

| Comments

Even when is not directly related to Angular, we need to fight with authentication from time to time. So let me explain what’s is this JWT (pronounced jot) which everybody is talking about.

I spent the last few weeks researching about auth methods so bear with me if I make a mistake and send a PR to amend it :P

Introduction to Unit Test: Filters

| Comments

Filters are the easiest components to test in Angular. That is why I decided to explain them first. Our first job is to decide what we want to achieve and in this case I decided to write a custom uppercase filter with options.

What should our filter do? Our filter will uppercase the entire input or just part of it based on an input. Let’s describe how we would like to use it here:

Transclusion and Scopes

| Comments

The problem

There is a common misconception that I see when I am doing Angular support. My goal here is to address it.

Let’s imagine I have this simple controller and directive:

Introduction to Unit Test: Spies

| Comments

Before we deep more into Angular lands, I want to talk about spies. No, no that kind of spies.

When you are doing unit testing, you don’t want to leave your SUT (subject under test) domain. If you’re testing a controller in Angular and it injects 3 services, you don’t care about those services, you only want to test that controller but also make sure it uses the services as intended.

Introduction to Unit Test: Introduction

| Comments

Let’s talk about unit testing our applications.

What is unit testing and why should I care?

Unit tests are a bunch of Javascript files that we create to make sure that every part of our application works as it is expected to work. That means that we need to write hundred of lines of code to assert that our code does what is supposed to do.

  • Isn’t that a waste of time? The boss is always telling us that we need to be faster and hundred of lines doesn’t sound like fast. Au contraire, that bunch of code will save us HOURS. Don’t believe me? I have proofs.