首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >App.reset()在ember qunit teardown失败

问App.reset()在ember qunit teardown失败
EN

Stack Overflow用户
提问于 2014-07-23 03:39:40
回答 1查看 441关注 0票数 1

我所有的ember-qunit测试都有一个类似的设置:

代码语言:javascript
复制
moduleFor('route:marketplace-search', 'Marketplace Search route', {
  setup: function() {
    setFixtures();
  },
  teardown: function() {
    App.reset();
  }
});

其中一个抛出错误:Uncaught TypeError: Cannot read property 'length' of null

这可以追溯到我的marketplace_search_spec.js文件中的App.reset()行:

代码语言:javascript
复制
DEBUG: ------------------------------- ember.js?body=1:14069
DEBUG: Ember      : 1.7.0-beta.1+canary.3d81867a ember.js?body=1:14069
DEBUG: Ember Data : 1.0.0-beta.9+canary.45d196b2 ember.js?body=1:14069
DEBUG: Handlebars : 1.3.0 ember.js?body=1:14069
DEBUG: jQuery     : 1.10.2 ember.js?body=1:14069
DEBUG: ------------------------------- ember.js?body=1:14069
Uncaught TypeError: Cannot read property 'length' of null ember.js?body=1:26529
__exports__.default.ArrayProxy.extend._resetSubControllers ember.js?body=1:26529
__exports__.default.ArrayProxy.extend.willDestroy ember.js?body=1:26542
apply ember.js?body=1:17952
superWrapper ember.js?body=1:17538
DeferredActionQueues.invoke ember.js?body=1:637
DeferredActionQueues.flush ember.js?body=1:687
Backburner.end ember.js?body=1:150
Backburner.run ember.js?body=1:205
apply ember.js?body=1:17955
run ember.js?body=1:16601
handleReset ember.js?body=1:2701
Backburner.run ember.js?body=1:201
apply ember.js?body=1:17955
run ember.js?body=1:16601
apply ember.js?body=1:17955
run.join ember.js?body=1:16643
Namespace.extend.reset ember.js?body=1:2710
moduleFor.teardown marketplace_search_spec.js?body=1:6
_callbacks.teardown ember-qunit.js?body=1:175
Test.teardown teaspoon-qunit.js?body=1:226
(anonymous function) teaspoon-qunit.js?body=1:366
process teaspoon-qunit.js?body=1:1455
(anonymous function) teaspoon-qunit.js?body=1:481

你知道为什么我会看到这个失败吗?

代码语言:javascript
复制
Failures:

  1) Marketplace Search route transitions to company.marketplace (1, 1, 2)
     Failure/Error: Teardown failed on transitions to company.marketplace: 'null' is not an object (evaluating 'subControllers.length')

Finished in 7.94400 seconds
127 examples, 1 failure
EN

回答 1

Stack Overflow用户

发布于 2014-07-24 00:32:45

正如@AmielMartin指出的那样,我的问题是由于没有在我的ArrayController上覆盖的控制器init函数中调用_super而引起的。

代码语言:javascript
复制
App.MarketplaceSearchController = Ember.ArrayController.extend({
  init: function() {
    this._super();
    // Do stuff here
  }
});
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24896351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档