为什么我可以创建一个窗口,这样就不会抛出这个错误?
throw new Error( "jQuery requires a window with a document" );
Error: jQuery requires a window with a document
这是我的app.js文件。
var Backbone = require('backbone');
var jquery = require('jquery');
var jsdom = require('jsdom');
var JournalView = Backbone.View.extend({
el: '#board',
initialize: function() {
this.render();
},
render: function() {
this.$el.html("Hello, world!");
},
});
var journalView = new JournalView();
答案 0 :(得分:0)
使用来自jsdom的window
这是一个例子:http://artsy.github.io/blog/2013/06/14/writing-headless-backbone-tests-with-node-dot-js/
jsdom.env({
html: "<html><body></body></html>",
done: function(errs, window) {
global.window = window;
// ...
callback();
}
});