2

我想使用visit帮助程序来集成测试以下路线:

App.IndexRoute = Em.Route.extend
    model: ->
        App.Movies.find "The Godfather"

但是我的测试没有通过,我得到:

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

不幸的是,像这样包装它并没有帮助:

App.IndexRoute = Em.Route.extend
    model: ->
        Em.run =>
            App.Movies.find "The Godfather"

(我也包了@App = Em.Application.create()

将代码包装到运行循环中的正确方法是什么?

我正在使用rc.5Karma。

4

2 回答 2

0

事实证明,我试图从中获取数据的服务器返回了404,这导致 Ember 断言。

修复服务器端 id 后发现根本不需要Em.run()

有关更多信息,请参见 GitHub:https ://github.com/emberjs/ember.js/issues/3051

于 2013-08-02T09:48:31.140 回答
-1

您如何为测试构建数据?它是应该包含在 Ember.run 中的部分(或设置属性)。

使用 FixtureAdapter,你应该有这样的东西:

Ember.run(function() {
  App.Movie.FIXTURES=[{ name: "the Godfather" }, { name: "Apocalypse Now" }];
});
于 2013-08-02T08:31:04.660 回答