Create a browser-like environment within a Node.js context
$ npm install node-as-browser
var nodeAsBrowser = require('node-as-browser');
nodeAsBrowser.init(global);
console.log(navigator.userAgent);
var nodeAsBrowser = require('node-as-browser');
var fakeWindow = {};
nodeAsBrowser.init(fakeWindow);
console.log(fakeWindow.navigator.userAgent);