簡體   English   中英

ember-qunit如何在集成測試中呈現組件?

[英]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如何預編譯模板?

編輯1

根據評論,我已經通過導入/導出將常規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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM