Skip to content

Instantly share code, notes, and snippets.

@drouillard
Created March 15, 2011 21:43
Show Gist options
  • Save drouillard/ccb8c45968c56654d191 to your computer and use it in GitHub Desktop.
Save drouillard/ccb8c45968c56654d191 to your computer and use it in GitHub Desktop.
jsdom example
var request = require('request'),
jsdom = require("jsdom"),
sys = require('sys');
request({uri:'http://www.google.com/'}, function (error, response, body) {
console.log('Initial Response Received');
if (!error && response.statusCode == 200) {;
var doc = jsdom.jsdom(body);
doc.onload = function() {
console.log('Document onLoad');
};
}
});
/*
From jsdom test suite
var doc = jsdom.jsdom(html), doc2;
doc.onload = function() {
assertEquals("js should be executed",
'hello from javascript',
doc.getElementById("test").innerHTML);
};
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment