javascript - 带有 Ember.testing = true 的 Ember.js

标签 javascript ember.js ember-data

我正在尝试在 Ember.js 中进行测试,并设置 Ember.testing = true 标志以禁用自动运行循环等

我有这个代码

Ember.testing = true;

Ember.run(function() {  
  App = Ember.Application.create();
});

App.Router.map(function() {
  this.route("home", { path: "/" });
});


Ember.run(function() {
  App.initialize();
});

我已经得到了 thuis 错误

Uncaught Error: assertion failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run 

我知道您需要在 Ember.run 中运行异步代码,根据我能找到的任何示例,我都有!!

谁能告诉我我做错了什么,甚至让 jsin 示例不显示此错误?

在这里查看 jsbin http://jsbin.com/uxalap/14/edit

更新:

我正在使用 Konacha 运行测试,当我使用最新的 RC1 时,在 Em.run 中包装 Ember.Application.create() 和 App.initialize() 时出现错误。当我删除这些时,我没有收到任何错误。这在最新的 master 中是否正确?

谢谢 瑞克

最佳答案

Ember.testing 自 RC1 以来已更改,如果你想使用它,你应该使用 master

Here's an updated working JSBin

关于javascript - 带有 Ember.testing = true 的 Ember.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15338081/

相关文章:

binding - 在各种过滤选项之间切换的正确 emberjs 方式是什么?

ember.js - ember-data fixture data "Cannot read property ' promise' of undefined"

java - 如何在没有 ember-cli 的情况下通过 PHP 或 java 使用 ember js?

javascript - 切换弹出窗口并在外部单击时切换它

javascript - 比较从数据库检索的两个日期

ember.js - Playframework 2.1 预编译 ember Handlebars

javascript - Ember : how to bind HTML class to Service property, 因此该类是动态的

ember.js - 如何使用 Ember 数据访问 json 中的嵌套对象

javascript - javascript中替代长度(不是32位)的整数

javascript - `reduce/scan` 的累加器函数中的可观察类型是否匹配?