Created
July 27, 2013 19:19
-
-
Save hpneo/6095953 to your computer and use it in GitHub Desktop.
Test JavaScript code with jsdom and express (using node.js)
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
| var jsdom = require("jsdom").jsdom; | |
| var document = jsdom(); | |
| var window = document.parentWindow; | |
| var express = require('express'); | |
| var app = express(); | |
| app.get('/', function(request, response) { | |
| var code = request.params.code || request.query.code; | |
| var func = new Function('window', code); | |
| response.json({ | |
| result: func.call(window, window) | |
| }); | |
| }); | |
| app.listen(4730); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment