我想在一页中呈现我的组件测试,这样我就可以看到我在某些方法中插入的调试。
出于某种原因,我的测试似乎没有正确加载数据,我想看看它正在加载什么。
不幸的是,QUnit 只显示我放入的内容asserts
,我想知道是否有办法在一个页面中查看我的测试,以便我可以看到控制台日志。
这是测试的骨架:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import { clickTrigger } from 'frontend/tests/helpers/ember-power-select';
moduleForComponent('dynamic-input-field', 'Integration | Component | dynamic input field', {
integration: true
});
test('it renders', function(assert) {
// Set any properties with this.set('myProperty', 'value');
this.set(...);
// render the component
this.render(hbs`{{my-component myProperty}}`);
// actions of user here
clickTrigger(); //this opens the ember-power-select
assert.equal($('.ember-power-select-dropdown').length, 1, 'Dropdown is rendered');
// check if it is rendering the elements and if it is excluding one element
assert.equal('Field Four',$($('.ember-power-select-option')[2]).text().trim());
});
编辑:我想出了什么问题只使用assert.equal()
。它缺少一个$()
(jQuery 函数)。例子:
assert.equal('Field Four',$($('.ember-power-select-option')[2]).text().trim());
看到渲染的组件仍然很棒,而不是玩assert.equal()