Skip to content

Instantly share code, notes, and snippets.

@y-li
Created June 20, 2012 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y-li/2958419 to your computer and use it in GitHub Desktop.
Save y-li/2958419 to your computer and use it in GitHub Desktop.
zombiejs example
var vows = require('vows')
var zombie = require('zombie')
var assert = require('assert')
vows.describe('TEST').addBatch({
'access homepage' : {
topic: function() {
zombie.visit('http://www.example.com/', this.callback)
},
'title: Example': function(browser) {
assert.equal(browser.evaluate('document.title'), 'Example')
},
'login': {
topic: function(browser) {
browser.fill('user_id', 'testuser')
.fill('user_password', 'testpassword')
.pressButton('Login', this.callback)
},
'redirected': function(browser) {
assert.equal(browser.redirected, true)
},
'URL: /top': function(browser) {
assert.match(browser.location._url.href, 'http://www.example.com/top')
},
'title: Top Page': function(browser) {
assert.equal(browser.evaluate('document.title'), 'Top Page')
},
'click test': {
topic: function(browser) {
browser.clickLink('TEST', this.callback)
},
'URL: /test': function(browser) {
assert.match(browser.location._url.href, 'http://www.example.com/test')
},
'title: TEST': function(browser) {
assert.equal(browser.evaluate('document.title'), 'TEST')
},
'click button': {
browser.fire('click', browser.query('Click Me'), this.callback)
},
'TEST link came out': function(browser) {
assert.equal(browser.text('a[href=http://test.example.com/]'), 'TEST')
}
}
}
}
}).export(module)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment