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

CSS Themes as white label

Recently, I had to add white-label support for the project.

This means, that some elements on screen had to be able to get theme-specific styling. Usually this mainly means theme-specific colors, but this can easily be extended to SVGs, graphics, Logos etc.

So, I came up with a neat CSS trick I’ll go over today.

Continue reading

TickerSrv – Timing service revamped

Mid 2014, I published a post about a timing service. You can read the post here.

Recently, I wanted to use this service for a client but the requirements meant that I had to refactor the code to be more robust.

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

Linking 2 local projects, without the Ugh factor

When working on a large scale application, eventually you’ll want to break it down to one or more product sub projects that all depend on a common project.

This post will discuss how to work with 2 projects properly while still using bower to manage dependencies

Continue reading

Free from include!

If you ever took part in any serious JS development in general and AngularJS specifically, you know that every time you create a new js file, you need to manually include a reference to it in the index.html file, other wise it won’t be included and the app will fail.

How would you feel about not having to do that?

Continue reading

AngularJS integration with Maven

When working on large scale projects, java back-end code is usually being built using Apache Maven.
This is usually part of a larger framework in charge of project life cycle that is part of the Continuous Integration DevOps realm, either Hudson, Jenkins or something else.
In such a case, you’d want your AngularJS code to run grunt/gulp as part of the CI procedure as well.

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

Timing service

Every once in a while, I find myself in need of a timing mechanism. Something that will handle timing and scheduling, and allow me to hook with a custom functionality every interval.

Some uses can be, for example, a clock counting down or simply showing the time passing by, polling the server back-end for new data, etc. Basically, anything that needs to happen every given interval.

Continue reading