Created
March 1, 2016 20:27
-
-
Save Jpunt/09dfa4d37f8d201d12d9 to your computer and use it in GitHub Desktop.
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
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); | |
console.log('ran:', ran); | |
</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