[英]How does ember-qunit render components in integration testing?
這是ember-qunit的基本組件/集成測試。
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('my-component', 'TODO: put something here', {
integration: true
});
test('it renders', function(assert) {
this.render(hbs`{{my-component}}`);
console.log('This is the rendered element', this.$()[0]);
assert.ok(false);
});
我有一個具有如下目錄結構的ember-addon:
addon/
.. components/
.... my-component/
...... component.js
...... style.less
...... template.hbs
app/
.. components/
.... my-component.js
...... component.js
tests/
.. integration/
.... components/
...... my-component-test.js
余燼如何確定{{my-component}}
在哪里?
與此類似:
Ember-CLI如何預編譯模板?
根據評論,我已經通過導入/導出將常規app
組件鏈接到了addon
組件。
app/components/my-component/component.js
export { default } from 'my-application/components/my-component'
但是,控制台日志僅顯示以下內容:
This is the rendered element <div id="ember234 class="ember-view">
<!---->
</div>
按照慣例。
灰燼嘗試在app/components
目錄或app/components/templates
目錄或app/helpers
目錄下找到名為my-component
的文件。
如果在addon/components
目錄下定義my-component
,則需要在app/components
目錄或tests/dummy/app/components
目錄下重新定義它,例如:
export { default } from 'my-addon/components/my-component';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.