使用select时,Ember.js测试失败

时间:2014-12-16 10:51:37

标签: ember.js

我正在使用Ember 1.8.1并且我从

更新了我的代码
{{view Ember.Select content=items}}

{{view "select" content=items}}

现在的问题是我的测试失败了,我收到了这个错误:

Error: Assertion Failed: select must be a subclass or an instance of Ember.View, not 
at new Error (native)
at Error.EmberError (http://0.0.0.0:4201/assets/vendor.js:27425:23)
at Object.Ember.assert (http://0.0.0.0:4201/assets/vendor.js:17039:15)
at handlebarsGetView (http://0.0.0.0:4201/assets/vendor.js:20093:13)
at EmberObject.create.helper (http://0.0.0.0:4201/assets/vendor.js:22801:19)
at viewHelper (http://0.0.0.0:4201/assets/vendor.js:23051:25)
at Object.anonymous (nea-client/templates/components/modal-workflow-create.js:18:54)
at http://0.0.0.0:4201/assets/vendor.js:10863:33
at CoreView.extend.render (http://0.0.0.0:4201/assets/vendor.js:55473:20)
at EmberRenderer_createElement [as createElement] (http://0.0.0.0:4201/assets/vendor.js:52700:16)

任何想法如何解决这个问题?如果我将代码恢复为旧样式,则测试通过,但我收到了弃用通知。

1 个答案:

答案 0 :(得分:5)

在你的测试中这样做:

import Ember from 'ember';

moduleForComponent('my-foobar', 'MyFoobarComponent', {
  setup: function() {
    this.container.register('view:select', Ember.Select);
  }
}

做这种事情让我们更接近集成测试。有关如何改善当前状态的讨论:https://github.com/rwjblue/ember-qunit/issues/74