Created
August 1, 2011 01:12
-
-
Save cpsubrian/1117422 to your computer and use it in GitHub Desktop.
Figuring out tests with Tobi and Vows.
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
/** | |
* When I try to test with my app ... I get the error below. | |
*/ | |
process.env['NODE_ENV'] = 'test'; | |
var vows = require('vows'), | |
tobi = require('tobi'), | |
should = require('should'), | |
app = require('../app'), | |
conf = require('../conf'); | |
/** | |
* Macros | |
*/ | |
var getBrowser = function() { | |
return tobi.createBrowser(app); | |
} | |
/** | |
* Tests | |
*/ | |
vows.describe('Post API').addBatch({ | |
'An unauthenticated visit to the front page': { | |
topic: function() { | |
var browser = getBrowser(); | |
browser.get('/', this.callback); | |
}, | |
'should have a status of 200': function(res, $){ | |
res.should.have.status(200); | |
}, | |
} | |
}).export(module); |
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
/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/level1/core.js:1275 | |
throw new core.DOMException(HIERARCHY_REQUEST_ERR); | |
^ | |
Error: Hierarchy request error | |
at Object.appendChild (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/level1/core.js:1275:13) | |
at setChild (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:167:17) | |
at HtmlToDom.appendHtmlToElement (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:77:9) | |
at Object.innerHTML (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/browser/index.js:398:27) | |
at Object.write (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom/level2/html.js:384:22) | |
at Object.jsdom (/var/www/node/wuzzup/node_modules/tobi/node_modules/jsdom/lib/jsdom.js:53:9) | |
at Browser.parse (/var/www/node/wuzzup/node_modules/tobi/lib/browser.js:93:23) | |
at IncomingMessage.<anonymous> (/var/www/node/wuzzup/node_modules/tobi/lib/browser.js:280:14) | |
at IncomingMessage.emit (events.js:81:20) | |
at HTTPParser.onMessageComplete (http.js:133:23) |
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
/** | |
* Changing the tobi.createBrowser call to google makes the test work. | |
*/ | |
process.env['NODE_ENV'] = 'test'; | |
var vows = require('vows'), | |
tobi = require('tobi'), | |
should = require('should'), | |
app = require('../app'), | |
conf = require('../conf'); | |
/** | |
* Macros | |
*/ | |
var getBrowser = function() { | |
return tobi.createBrowser(80, 'www.google.com'); | |
} | |
/** | |
* Tests | |
*/ | |
vows.describe('Post API').addBatch({ | |
'An unauthenticated visit to the front page': { | |
topic: function() { | |
var browser = getBrowser(); | |
browser.get('/', this.callback); | |
}, | |
'should have a status of 200': function(res, $){ | |
res.should.have.status(200); | |
}, | |
} | |
}).export(module); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this working-test still work for you?