当我在 mixin 的单元测试中执行 Ember.Component.Create() 时,我得到了这个错误。我正在将 ember 从 1.13 升级到 2.10,此测试在 1.13 中运行良好,但在 2.10 中出现此错误。看起来在 2.10 ember 组件初始化需要一个应用程序实例。
Died on test #1 at Module.callback (http://localhost:4200/assets/tests.js:250:19)
at Module.exports (http://localhost:4200/assets/vendor.js:131:32)
at requireModule (http://localhost:4200/assets/vendor.js:30:18)
at TestLoader.require (http://localhost:4200/assets/test-support.js:7104:7)
at TestLoader.loadModules (http://localhost:4200/assets/test-support.js:7096:14)
at Function.TestLoader.load (http://localhost:4200/assets/test-support.js:7126:22)
at http://localhost:4200/assets/test-support.js:7009:18: Cannot instantiate a component without a renderer. Please ensure that you are creating <(subclass of Ember.Component):ember210> with a proper container/registry.@ 9 ms
Source:
Error: Cannot instantiate a component without a renderer. Please ensure that you are creating <(subclass of Ember.Component):ember210> with a proper container/registry.
at Class.init (http://localhost:4200/assets/vendor.js:51954:15)
at Class.superWrapper [as init] (http://localhost:4200/assets/vendor.js:50175:22)
at Class.init (http://localhost:4200/assets/vendor.js:50443:19)
at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
at Class.init (http://localhost:4200/assets/vendor.js:50493:19)
at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
at Class.exports.default._emberMetal.Mixin.create._Mixin$create.init (http://localhost:4200/assets/vendor.js:51000:17)
at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
at Class.init (http://localhost:4200/assets/vendor.js:17472:19)
at Class.superWrapper [as init] (http://localhost:4200/assets/vendor.js:50175:22)
我尝试过的几件事:
在 setup 和 destroy 中启动 App(),类似于集成测试
要覆盖 init 但 init 总是需要调用 _super()
试图在创建应用程序的集成测试环境中执行