我无法在我的ember应用程序中为应用程序路由设置单元测试。
非常简单的路径:
import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin, {});非常简单的测试:
import {
moduleFor,
test
} from 'ember-qunit';
import { authenticateSession } from '../../helpers/ember-simple-auth';
moduleFor('route:application', {
beforeEach: function(){
this.subject().set('session', authenticateSession);
},
});
test('it exists', function(assert) {
var route = this.subject();
assert.ok(route);
});我尝试了几种方法,但它们都抛出了错误:
Promise rejected before it exists: 'undefined' is not an object (evaluating '_this.get('session').on')这似乎表明会话在mixin中是未定义的,有没有人可以进行单元测试?我可以转换为集成测试,但如果可能的话,我更愿意将其保留为单元级别。
发布于 2016-01-21 10:07:55
如果其他人遇到这种情况,它只是一个"needs:'service:session'“,在这里的另一个答案中可以找到:
https://stackoverflow.com/questions/34902147
复制相似问题