gpt4 book ai didi

javascript - 引用错误: Can't find variable - Qunit Testing with ember in rails

转载 作者:行者123 更新时间:2023-12-02 17:59:03 25 4
gpt4 key购买 nike

所以我有以下文件:

应用程序/ Assets /javascripts/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

发生什么事了?我的应用程序在非测试时加载良好,但在设置它进行测试时我收到了这些错误。

最佳答案

听起来好像 js 文件被乱序插入。 (例如app/assets/javascripts/aisis_planner.js之前的tests/javascripts/test_helper.js)

关于javascript - 引用错误: Can't find variable - Qunit Testing with ember in rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20716649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com