我正在嘗試編寫渲染句柄組件的單元測試。當測試運行時,對象爲空,並且不生成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