While the initial announcement was pretty complete in its run down of how to write tests, I had to look around a bit to figure out how to install and actually run the tests. In case anyone else new to node.js is struggling, here’s what I had to do:
1. Install node and npm
I knew what node was, but I hadn’t heard of its package manager, NPM. I’m using OS X with homebrew already installed, which means that I can just run:
brew install node npm
2. Set NODE_PATH
I may have missed this in the instructions, but eventually figured out I had to set a NODE_PATH variable. If you’re using homebrew, add this to your bash profile and source it or start a new terminal session:
3. Install zombie.js via npm
NPM is similar to many other package managers out there. For example, to install zombie you just need to run:
npm install zombie
npm list installedwill show you what packages you have installed on your local system. zombie and a couple others (like jsdom) should be there.
4. Run a Test
I found some problems with some rather well-known sites (Google, Wikipedia, and the W3C Validation Service—see this ticket), however I was able to get a working test with the barest of HTML. It would appear that these types of errors are more easily avoidable if you’re starting a project from scratch.
Zombie test script:
Run the zombie script with
node visit_click_me.jsand you should be on your way.
Off to Spread the Zombie Plague
I’m pretty excited to see what I can do with this. I’d like to thank Assaf and all of the contributors for all of their hard work.