I've been working with Jasmine to test my client side code, however, my code extends beyond the client. I am working on server side JavaScript using Node.js. It would be great to apply my test driven process to my node server as well. Luckily, the Node community is large, helpful, and talented. Jasmine has been ported to the server with the jasmine-node project by Miško Hevery (https://github.com/mhevery/jasmine-node). The github readme summarizes the process of setting up jasmine-node, so this post will expound on those points.
12/31/2012
12/17/2012
Building a Unit Test in Jasmine, Part 4
The last part in this series is going to involve some time travel. Physics
aside, let's assume six months have passed since our original JasmineTester
object was created. The object was a great success and has been embedded
all throughout the organization. We have forgotten the details of our
earlier work as multiple other projects have come and gone. While still
basking in the glow of our earlier success, a new requirement comes down the
line: make a new object exactly like the JasmineTester but with multiplication. Thanks
goodness we used Jasmine!
12/03/2012
Building a Unit Test in Jasmine, Part 3
We created a Jasmine unit test example in the first two parts of this series that started with a statement and then abstracted out to an object. This time we will expand the object to be more robust. Most importantly, we are not changing the tests currently in place.
The JasmineTester is going to be updated to accept a random number of values. The first step is to create a unit test to describe this. The number of properties being added is upped to 4. The new test will check to make sure the new object constructor still returns an object by using the toBeDefined matcher.
The JasmineTester is going to be updated to accept a random number of values. The first step is to create a unit test to describe this. The number of properties being added is upped to 4. The new test will check to make sure the new object constructor still returns an object by using the toBeDefined matcher.
11/27/2012
Solve the Problem, Not the Behavior
In my past life of consultancy I became very used to working on other people's code. One of the most important lessons I learned was to "find the problem first". Errors are a behavior you witness. Debugging is fixing those errors. Most developers would consider those reasonable statements. There is an underhanded trick here though. Some developers might make the mistake of a direct connection between the two, but there isn't. The error you witness may not be the error you need to fix.
11/26/2012
Building a Unit Test in Jasmine, Part 2
In the previous part, I showed an extremely simple test whose only purpose is to highlight how Jasmine works. This post will take those pieces and start doing something more dynamic with our source code. The Source and the Spec are going to change.
One reason to unit test is to confirm your code works despite internal changes to the source. As your application changes and matures, it can be daunting to ensure your old code still works. Properly created and maintained unit tests make this much less scary. You add a feature, run all your tests. Everything passes, then you are in good shape. If something breaks, you know it now and not when the customer finds it. Once everything passes you can move on to your next set of changes with relative certainty your application still works. This post will set us up to show that principle in action over the next 2 posts.
One reason to unit test is to confirm your code works despite internal changes to the source. As your application changes and matures, it can be daunting to ensure your old code still works. Properly created and maintained unit tests make this much less scary. You add a feature, run all your tests. Everything passes, then you are in good shape. If something breaks, you know it now and not when the customer finds it. Once everything passes you can move on to your next set of changes with relative certainty your application still works. This post will set us up to show that principle in action over the next 2 posts.
11/12/2012
Building a Unit Test in Jasmine, Part 1
(Thanks to Dustin Butler for the inspiration that led me down this path. His great and more in-depth article is at Unit Test JavaScript Applications with Jasmine)
Unit testing and I have had a tumultuous affair until now. Every few months I would pick up a book, go on a blog reading binge, or try out a framework. It would never work out. I would get frustrated or work would intervene and off I went. Unit testing and I were almost fated to always be apart... <cue the romantic music>
An opportunity came at work to create a new feature on our web platform. I decided to take a chance and build it from unit tests. It was a great opportunity to start clean with very few dependencies to worry about. The lack of entanglements made it easier for me to understand how unit testing would work to describe this new piece.
Unit testing and I have had a tumultuous affair until now. Every few months I would pick up a book, go on a blog reading binge, or try out a framework. It would never work out. I would get frustrated or work would intervene and off I went. Unit testing and I were almost fated to always be apart... <cue the romantic music>
An opportunity came at work to create a new feature on our web platform. I decided to take a chance and build it from unit tests. It was a great opportunity to start clean with very few dependencies to worry about. The lack of entanglements made it easier for me to understand how unit testing would work to describe this new piece.
10/29/2012
Bubbling in Enyo2, Part 3
Our first example was a simple event bubble from a button to a parent object. The second example re-used the button object within two separate parents that handled the bubbled event differently. Let's go one step farther. This time the button's event will bubble all the way up the parent hierarchy.
10/21/2012
Bubbling in Enyo2, Part 2
We looked at a simple example in Part 1. A button component sent an event up the object hierarchy until it was captured by the App kind and resolved. Wouldn't it be great if we could use the same BubbleButton kind in 2 different hierarchies and get 2 different results? Yes it would; so let's do that.
10/15/2012
Bubbling in Enyo2, Part 1
"Bubble, bubble, toil and trouble" cry the witches of Macbeth. Clearly, they never tried using Enyo 2 as their JavaScript framework or it would have been "Bubble, bubble, yahoo!". The event bubbling system is one of the features that makes Enyo 2 feel so powerful.
The bubble method allows events to be sent up the object hierarchy. This is not the same thing as bubbling up the DOM. The object structure that is in memory can be similar to the DOM, but the process will only work against the object hierarchy. Changes to the DOM will need to be rendered separately.
The bubble method allows events to be sent up the object hierarchy. This is not the same thing as bubbling up the DOM. The object structure that is in memory can be similar to the DOM, but the process will only work against the object hierarchy. Changes to the DOM will need to be rendered separately.
Subscribe to:
Posts (Atom)