Skip to content

Instantly share code, notes, and snippets.

@cpsubrian
Created August 1, 2011 01:12
Show Gist options
  • Save cpsubrian/1117422 to your computer and use it in GitHub Desktop.
Save cpsubrian/1117422 to your computer and use it in GitHub Desktop.
Figuring out tests with Tobi and Vows.
/**
* 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);
/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)
/**
* 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);
@cmeiklejohn
Copy link

Does this working-test still work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment