I'm trying to run my usual jasmine-node tests with ember.js and because ember requires handlebars to be loaded I included that library also.
Yet for some reason when ember hits this code
window.Handlebars
I get undefined.
Here is how i'm loading jquery/handlebars/ember in my jasmine tests
var jsdom = require("jsdom");
window = jsdom.jsdom("<html></html");
global.window = window;
require("path/to/jquery");
require("path/to/handlebars-1.0.0.beta.6");
require("path/to/ember-1.0.pre");
describe("test demo", function() {
it("should not blow up when running this", function() {
expect(2).toBe(2);
});
});
I could easily hack this into the bottom of the handlebars.js file but I'd like to understand what else could be done to avoid having to modify this library directly for tests.
window.Handlebars = Handlebars;
(followed by this line before I load ember in the helper)
global.Handlebars = window.Handlebars;
** update **
I also have the same problem with ember-data.js
It seems that setting window.Foo is not enought -instead I actually need to set global.Foo (any ideas on a work around for this?)
(function() {
window.DS = Ember.Namespace.create({
CURRENT_API_REVISION: 4
});
})();
global.DS = window.DS; //I had to add this to make DS available