When you require("d3"), it creates a window and a document and
includes JSDOM for you. So you can say something like this:
var d3 = require("d3");
d3.select("body").append("div")
.attr("id", "chart")
.append("svg")
.attr("id", "background")
.attr("width", 750)
.attr("height", 750);
And then:
> window.document.innerHTML
'<html><head></head><body><div id="chart"><svg id="background"
width="750" height="750"></svg></div></body></html>'
Of course, this is missing <!DOCTYPE html>, so don't forget to add
that. Also, note that JSDOM doesn't really know about SVG. It will
still create SVG elements, but it doesn't support SVG's special APIs
(e.g., getBBox). Depending on what you are trying to do, you might
have better luck with PhantomJS.
Mike