From the comment I gather you want to manipulate the DOM in JSDOM in node and then (maybe) write an html file (or return it in a response)
For that use serialize()
So with your example:
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM(`
My First JSDOM!
`,{
url: "http://localhost:3000/",
contentType: "text/html",
pretendToBeVisual: true,
}
);
console.log(dom.serialize());
JSDom will give you a string for all your HTML.
You can then use Express.js to create a server that may return that HTML or you use the string to write an HTML file to disk.
const express = require('express');
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM(`
My First JSDOM!
`,{
url: "http://localhost:3000/",
contentType: "text/html",
pretendToBeVisual: true,
}
);
const app = express();
app.get('/', (req, res) => {
res.send(dom.serialize());
});
app.listen(8080, () => {
console.log('Example app listening at http://localhost:8080');
});