Behavior Driven Behavior Driven Development

Like all true CS aficionados I have a thing for recursively applying layers of abstractions on top of themselves. Makes for interesting stories.

I have been using much more javascript than I ever thought I would. And, I like it for the most part. But, there is this niggly feeling in the back of my head because I’ve been doing so without a snuggly net of tests. Or even specs.

I looked at jsunit, jsspec and Screw.Unit. But, I didn’t really like the way they worked. So, in the usual way of things. I started on my own.

The first thing I didn’t like about the frameworks when I started looking at them was that they tried to avoid adding things to Object.prototype. Which makes it more difficult to do rspec style expectations like(ruby not js)

"foo".should include('oo')

because should is not available to “foo”

mostly, they get around this by using wrapper functions.




when what I want is


It is silly, I know but I got use to rspec and I want my javascript specs to be as free of line noise. Hanging stuff off of Object.prototype is the easy way to do this, but it can break things. Mostly for (… in … ) loops. Arguably, you shouldn’t use those for much anyway. They are dangerous in some circumstances. That’s mostly an opinion thing, though.

The other problem I had was finding coherent documentation. All of the js testing frameworks have fairly good documentation, but I had some trouble figuring out what was the most current practice. Some jsspec looks a lot like what I am looking to do. But now I have started, and it is an interesting project.

The project I am using it for is a gomoku game, maybe backed up by sinatra at some point, but for now it is just js.

I am planning on posting some code later, right now it doesn’t even have setup hooks.

Comments are closed.