Dienstag, 12. August 2014

JavaScript CI - The Next Generation

A few months back, I start working with JavaScript. Since I am full convinced about the benefits of the Continuous Integration (CI) methodology, I have start to get familiar with CI in the context of JavaScript.
CI is a methodology which can be adopt in any language, but because I am familiar with CI in the context of Java, i.e. I am working with Java for some years; I will present the tools for CI in Javascript as a parallel for the tools I use in Java.
Of course, it can be that there are better suited tools for the job, but the tools I will present are doing a great job for me and work great.

As a CI Server I will go also with Jenkins which is doing a great job.
In order to have CI we will need to have test that can be run automatically. Mostly for Test in Java I use TestNG as a library, but also in this area is a new player in town Spock. I have start using Spock  in Grails and it's very expressive. You should give it a try ;).
For the JavaScript there are also plenty of  testing framework. I have started with Jasmine and stick with it because it's more then just a testing framework, it's supports also BDD and in some how I find't expressive like Spock.
The second tool it will be  Karma which is a test runner. Sorry if I go to far with the analogy, but I will say that Karma is the equivalent of the Surefire Plugin in Java, i.e. it also executes the test independent from the test library and generates, depending on the configuration, different reports e.g. coverage, unit-test.

After creating the test in Java, mostly we have a helper which, with regard to test, is putting all together: with only one command we have in a moment the tests run and different operating figures generated e.g. tests result, tests coverage, statical analysis etc. In Java, for me, those helper are Ant, Maven and also here as new player Gradle. In terms of JavaScript I will start the introduction with Grunt which is a task runner and in my analogy to Java context, I will say that Grunt is the Ant for JavaScript.

There is one more thing which is missing: a dependencies resolver. For Java Maven is doing a great job. For JavaScript at the moment are some more options, all of them with theirs  pro's and con's. The tools that I use are Bower and Nmp as a part of Node.js.

That was just a short presentation of the tools I recommend you to use when you want to start to develop with joy awesome JavaScript application.

In other words as Spock will say code -"live long and prosper"