Created
June 30, 2011 11:10
-
-
Save pzel/1056023 to your computer and use it in GitHub Desktop.
unable to fire event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zombie = require('zombie'); | |
assert = require('assert'); | |
vows = require('vows'); | |
url = "http://localhost:4568/"; | |
// Load the page from localhost | |
vows.describe('The tags page').addBatch({ | |
'Presence' : { | |
topic : function() { | |
//The zombie callback is a function with three args: | |
// function(error, browser, status){...}; | |
zombie.visit(url + "tags", this.callback); | |
}, | |
'should be ok': function(e, b, s){ | |
assert.equal(s, "200"); | |
}, | |
'should have the right title': function(e,b,s){ | |
assert.equal(b.text("#header > h1"), "All tags"); | |
} | |
}, | |
'Adding a new tag': { | |
topic: function(){ | |
zombie.visit(url+"tags", this.callback); | |
}, | |
'after submitting tag name': { | |
topic : function(b) { | |
b.fill("tag[content]", "holograms"). | |
pressButton("Add tag", this.callback); | |
}, | |
'it should be successful' : function(b) { | |
assert.equal(b.response[0], "200"); | |
}, | |
'it should show the new tag' : function(b) { | |
assert.ok(b.querySelector(".info_for_tag")); | |
assert.match(b.text(".info_for_tag a"), /\s*holograms\s*/); | |
}, | |
'after hovering on new tag' : { | |
topic : function(b) { | |
// This function does not work *error message below | |
b.fire("mouseOver", '.info_for_tag'); | |
// This doesn't work either | |
// b.fire("click", '.info_for_tag a'); | |
b.wait(this.callback); | |
}, | |
'it should change class' : function(b){ | |
console.log(b.response[2]); | |
assert.ok(b.querySelector(".unused_tag")); | |
} | |
} | |
} | |
} | |
}).export(module); | |
/* THE ERROR MESSAGE */ | |
♢ The tags page | |
Presence | |
✓ should be ok | |
✓ should have the right title | |
Adding a new tag after submitting tag name | |
✓ it should be successful | |
✓ it should show the new tag | |
node.js:134 | |
throw e; // process.nextTick error, or 'error' event on first tick | |
^ | |
TypeError: Object .info_for_tag a has no method 'dispatchEvent' | |
at Browser.fire (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:173:14) | |
at Object.<anonymous> (/home/p/code/nejiro/spec/js/ajax_test.js:42:23) | |
at run (/home/p/code/nejiro/node_modules/vows/lib/vows/suite.js:130:31) | |
at EventEmitter.<anonymous> (/home/p/code/nejiro/node_modules/vows/lib/vows/suite.js:203:40) | |
at EventEmitter.emit (events.js:81:20) | |
at /home/p/code/nejiro/node_modules/vows/lib/vows/context.js:32:52 | |
at /home/p/code/nejiro/node_modules/vows/lib/vows/context.js:46:29 | |
at Browser.<anonymous> (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:148:18) | |
at Browser.<anonymous> (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:9:60) | |
at Browser.emit (events.js:64:17) | |
It's very nice. There is much less slowness and fuss than with selenium, and you don't have to write tests in tedious js (like with zombie or phantom). Here is the capybara-webkit version of the above code, running on rspec.
I'm writing my tests in coffeescript and using vows-bdd to run them, so it's not as tedious as js + vows. Is it possible to test a node.js app from capybara-webkit?
I think it should be, but you would probably have to write the tests themselves in ruby.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool, how is capybara-webkit working out for you so far? Do you have the above test written in capybara-webkit that I can reference? I might have to take a look, as 've been persevering with zombie and it's taking a lot of time to work around it's limitations, also there's not much support when things go wrong unfortunately :(