我在 controllers/order.js 中有一个订单控制器
import Ember from 'ember';
export default Ember.Controller.extend({
needs: "orders"
});
这在 /tests/unit/controllers/order-test.js 中有一个测试
import { moduleFor, test } from 'ember-qunit';
moduleFor('controller:order', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
var controller = this.subject();
assert.ok(controller);
});
router.js 看起来像这样
this.resource('orders', function() {
this.resource('order', { path: ":order_id"} , function() {
});
this.route('create');
});
我的想法是我有一个 /orders/ 路线,其中有人单击表格中的订单,然后在表格下方显示有关订单的更多详细信息,例如路线现在是 /orders/1。
单元测试失败:
Died on test #1 at Object.test (http://localhost:4200/assets/test-support.js:1644:11)
at http://localhost:4200/assets/orders-app.js:1464:15
at mod.state (http://localhost:4200/assets/vendor.js:150:29)
at tryFinally (http://localhost:4200/assets/vendor.js:30:14)
at requireModule (http://localhost:4200/assets/vendor.js:148:5)
at Object.TestLoader.require (http://localhost:4200/assets/test-loader.js:29:9)
at Object.TestLoader.loadModules (http://localhost:4200/assets/test-loader.js:21:18): <(subclass of Ember.Controller):ember216> needs [ controller:orders ] but it could not be found
Error: <(subclass of Ember.Controller):ember216> needs [ controller:orders ] but it could not be found
at new Error (native)
at Error.EmberError (http://localhost:4200/assets/vendor.js:22707:21)
at verifyNeedsDependencies (http://localhost:4200/assets/vendor.js:13783:13)
at ControllerMixin.default.reopen.init (http://localhost:4200/assets/vendor.js:13865:11)
at superWrapper [as init] (http://localhost:4200/assets/vendor.js:27980:20)
at new Class (http://localhost:4200/assets/vendor.js:41203:14)
at Function.ClassMixinProps.create (http://localhost:4200/assets/vendor.js:41625:14)
at exports.default.klassy.Klass.extend.defaultSubject (http://localhost:4200/assets/test-support.js:2188:22)
at Object.exports.default.klassy.Klass.extend.contextualizeCallbacks.context.(anonymous function) [as subject] (http://localhost:4200/assets/test-support.js:2209:41)
at Object.<anonymous> (http://localhost:4200/assets/orders-app.js:1465:27)
我需要在设置或测试中进行哪些更改才能使单元测试在此处通过?