Skip to content

Instantly share code, notes, and snippets.

@Trindaz
Created June 5, 2012 22:13
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 Trindaz/2878441 to your computer and use it in GitHub Desktop.
Save Trindaz/2878441 to your computer and use it in GitHub Desktop.
var jsdom = require('jsdom');
var body1="<html><head>"+
"<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key=***key***&sensor=false'></script>"+
"<script type='text/javascript' src='https://raw.github.com/gist/2878326/f2d5d46b07a9f425870fa025c2cfbeb379c41a67/gistfile1.js'></script></head>"+
"<script>functions testMe(){ var a = 1;}</script>"
"<body>"
"<div><form id='addressform'>"+
"<input id='address' class='address' type='textbox' value='1 Market St, San Francisco'>"+
"<input id='test' class='test' type='textbox' value='not tested'></form></div></body>"+
"</html>";
jsdom.env({
html:
body1,
scripts:
[
'http://code.jquery.com/jquery-1.5.min.js'
],
done:
function (err, window) {
try{
window.testMe(); //this line breaks
console.log(window.$('html').html());
}catch(err){
console.log(err);
}
},
features :
{
FetchExternalResources : ['script'],
ProcessExternalResources : ['script']
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment