Last active
March 1, 2016 20:27
-
-
Save JasperH8g/01134873c76126f36159 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const jsdom = require("jsdom"); | |
jsdom.env({ | |
html: ` | |
<!DOCTYPE html> | |
<body> | |
<script> | |
var script = document.createElement("script"); | |
script.setAttribute('type', 'application/javascript'); | |
script.textContent = "ran = true;"; | |
document.body.appendChild(script); | |
setTimeout(function() { | |
console.log('ran:', ran); | |
}, 0); | |
</script> | |
</body> | |
`, | |
features: { | |
FetchExternalResources: ["script"], | |
ProcessExternalResources: ["script"] | |
}, | |
virtualConsole: jsdom.createVirtualConsole().sendTo(console), | |
done: (err, window) => { | |
if (err) { | |
throw err; | |
} | |
console.log(window.ran); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment