Skip to content

Instantly share code, notes, and snippets.

@hpneo
Created July 27, 2013 19:19
Show Gist options
  • Save hpneo/6095953 to your computer and use it in GitHub Desktop.
Save hpneo/6095953 to your computer and use it in GitHub Desktop.
Test JavaScript code with jsdom and express (using node.js)
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