我正在尝试编写渲染句柄组件的单元测试。当测试运行时,对象为空,并且不生成HTML。我已经使用其他组件跟随此相同的布局,并且它们正确渲染。我很困惑,为什么返回的对象为null /未定义Ember单元测试渲染句柄返回null或undefined
这里是我的余烬测试代码:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('csv-upload', 'Integration | Component | csv upload', {
integration: true
});
test('it renders', function(assert) {
assert.expect(2);
this.render(hbs`{{csv-upload}}`);
assert.equal(this.$().text().trim(), '');
// Template block usage:
this.render(hbs`
{{#csv-upload}}
template block text
{{/csv-upload}}
`);
assert.equal(this.$().text().trim(), '');
});
从测试的输出是:
ok 32 PhantomJS 2.1 - JSHint - integration/pods/components/csv-upload/component-test.js: should pass jshint
not ok 33 PhantomJS 2.1 - Integration | Component | device actions: it renders
---
actual: >
null
从输出另一件事:
undefined is not an object (evaluating 'this.get('selected').isAny')
谢谢!我会投票答复 – ajputnam