所以我有以下文件:
应用程序/资产/ Javascript角/ aisis_planner.js
//= require handlebars
//= require ember
//= require ember-data
//= require_self
//= require ./store
//= require_tree ./models
//= require_tree ./controllers
//= require_tree ./views
//= require_tree ./helpers
//= require_tree ./components
//= require_tree ./templates
//= require_tree ./routes
//= require ./router
window.AisisPlanner = Ember.Application.create();
然后在tests / javascripts / test_helper.js
下//= require application
//= require_tree .
//= require_self
//= require aisis_planner
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
document.write('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>');
AisisPlanner.rootElement = '#ember-testing';
AisisPlanner.setupForTesting();
AisisPlanner.injectTestHelpers();
function exists(selector) {
return !!find(selector).length;
}
但是在转到localhost:3000/qunit
时,我一直收到错误:
ReferenceError: Can't find variable: AisisPlanner
怎么回事?我的应用程序加载正常,非测试,但是当它设置为测试我得到这些错误。
答案 0 :(得分:2)
听起来像js文件正在按顺序插入。 (例如app / assets / javascripts / aisis_planner.js之前的tests / javascripts / test_helper.js)