Jasmine describe override

Say you want to test your Angular application.

To do that you’ll be implementing Unit tests (with the Jasmine + Karma + PhantomJS stack) or E2E tests (with the Jasmine + Protractor stack).
You could choose any other stack using Cucumber, mocha, chai or any other testing framework – the principle of today’s topic remains the same.

The scenario is this:
There’s this piece of setup code that needs to be executed before each spec in every suite (performing login, for example).
I chose before each spec for the sake of the argument, but the same concept could be applied to before all specs in the suite and/or after each and after all specs in the suite.

for the sake of the post: describe = suite and it = spec.

Continue reading

Jasmine tests – setup describe

When I published the post about the Local Storage Cache Service, I also published the service code and test on GitHub.

This raised quite a few questions from readers in regards to the test. Specifically, why I implemented it with a main describe that contained an inner setup describe and an inner tests describe.

Continue reading

Your very own Font Awesome font

Ever since Font Awesome came out, I was amazed at how simple it made things.
It really is… well… Awesome!

Working with graphics or icons was never a major hassle but using icons as a font has so much more going for it!

Continue reading

Jasmine tests – expect().toThrow()

Suppose you have a service that you want to test.
And let’s also suppose that this service has a method that throws an Error under some scenario.

How would you test this?

Continue reading