Posts

Showing posts from November, 2015

How to mock properly the services in AngularJS

Image
//English As you may know, there's a lot of posts about how to create unit tests in AngularJS, you can find a lot of results in Google, but after a long time working with Angular I found that those posts are incomplete! why? simple, they tell you how to test controllers but each post I read tell you to inject the needed services, this is wrong because what happen if the service is incomplete or maybe someone introduce a bug on the latest commit? then that unit test will fail and it will fail not because the functionality to test is failing, it will fail because a dependency that we can mock... Let's take this controller as example: Loading... https://gist.github.com/3672831a21169e9deac9.git As you can see, the controler will fetch the new values from the server, following the good practices that Ajax call will be stored in a factory or service, so the controller will do what a controller should do: just be the "glue" between the view and the model :) N

NICE NODE MODULES! - Rest Facade

//English Hi guys, yesterday I was playing a little bit with a module that I saw on Twitter : Rest Facade ! Basically this module abstracts the process of consuming REST endpoints! I don't need to explain you too much about it, because its documentation is pretty much straight forward, please see below the code of the examples that I did: Loading... https://gist.github.com/92db9047ca5d8d07ae44.git As you can see, even if you don't read the documentation, you can understand pretty well the code. To see this example working, you can go to my c9 , the same code is there, you just need to run it as we normally do on node =D. NOTE : You can check the same code on my Github Well guys, if you have doubts, please let me know, I'm going to do my best to answer :) //EspaƱol Hola! ayer estuve jugando un poco con un nuevo modulo que vi en Twitter : Rest Facade ! Basicamente este modulo encapsula el proceso de consumir REST APIs La verdad es que no necesito e

Webpack Overview

Image
//English Hi guys, since the last weeks I've been trying something different than the usual, you may know that I love gulpJS, but I found a new "task-runner": Webpack! <!-- WTF is Webpack? --> To be honest, Webpack isn't a "task-runner", It's a module bundler. What this means is that Webpack takes your src code and transforms it into one single file which has all your src code organized as you have but improving the repeating calls, requires, imports, etc. Why is this important? well the heavier your files are, the more time it takes to download and render your website. Webpack is meant to be a single module bundler for all your Web Apps. This means that you only need Webpack, not anything else, for instance: You have an SPA that needs Angular to work but instead of using purely JS, you decide to use coffeescript, then you can use gulp and create a task called: bundle-js and add the proper pipes, right? Well with Webpack, this process i