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 npm2. 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:
export NODE_PATH="/usr/local/homebrew/lib/node"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 zombieRunning
npm list installed will 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.
HTML:
Zombie test script:
Run the zombie script with
node visit_click_me.js and 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.
hi this was useful .. i trying something like login first,it will take me to dashboard page ,i can capture the dashboard page html ,but not able to do any events like setting values to text box ,zombie is not able to find any Id's in that page..
ReplyDeleteI am learning zombie/node js and used your click_me.html example and am receiving this last Response error:
ReplyDeletenode click_me.js
Zombie: GET http://localhost/click_me.html => 200
Zombie: GET http://localhost/clickme.html => 200
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'lastResponse' of undefined
at Array.0 (/root/node_modules/zombie/click_me.js:12:28)
at EventEmitter._tickCallback (node.js:192:40)
node version is v0.6.17.
thanks in advance.