我想使用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.5和Karma。
发布于 2013-08-02 09:48:31
结果是,我试图从返回的404中获取数据的服务器导致Ember断言。
在修复服务器端之后,id发现根本不需要Em.run()。
有关更多信息,请参见GitHub:https://github.com/emberjs/ember.js/issues/3051
发布于 2013-08-02 08:31:04
如何为测试构建数据?应该将该部分(或设置属性)包装在Ember.run中。
使用FixtureAdapter,您应该有如下内容:
Ember.run(function() {
App.Movie.FIXTURES=[{ name: "the Godfather" }, { name: "Apocalypse Now" }];
});https://stackoverflow.com/questions/17812244
复制相似问题