Created
March 15, 2011 21:43
-
-
Save drouillard/ccb8c45968c56654d191 to your computer and use it in GitHub Desktop.
jsdom example
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 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