-
-
Save sposmen/10729648 to your computer and use it in GitHub Desktop.
Emulate browser inside nodejs
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 window; | |
if (typeof window === "undefined" || window === null) { | |
window = {}; | |
} | |
if (typeof jQuery === "undefined" || jQuery === null) { | |
global.$ = require('jquery'); | |
} | |
if (typeof _ === "undefined" || _ === null) { | |
global._ = require('underscore'); | |
} | |
if (typeof Backbone === "undefined" || Backbone === null) { | |
global.Backbone = require('backbone'); | |
} | |
if (typeof Mustache === "undefined" || Mustache === null) { | |
global.Mustache = require('../lib/mustache'); | |
} | |
if (typeof localStorage === "undefined" || localStorage === null) { | |
global.localStorage = require('localStorage'); | |
} | |
if (typeof Store === "undefined" || Store === null) { | |
global.Store = require('../lib/backbone.localStorage'); | |
} | |
global.jsdom = require("jsdom").jsdom; | |
global.document = jsdom('<html><body></body></html>'); | |
global.window = document.createWindow(); | |
global.navigator = { | |
browser: 'foo' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment