2016-08-30 7 views
1

ここにember-qunitの基本的なコンポーネント/統合テストがあります。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); 
}); 

私はこのようなディレクトリ構造を持つ残り火アドオンを持っています

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}}がどこにあるエンバーが決定しない方法は?

これは、これと同じ調子で一種のです、私はちょうどエクスポート/インポートすることにより、addonコンポーネントを定期的にappコンポーネントをリンクした
How does Ember-CLI precompile templates?

編集コメントを1として1

それ。

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> 

答えて

2

を。

Ember 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'; 
+0

二つの質問。まず、コンポーネントの他の部分(テンプレートやスタイル(更新されたファイル構造)を含む)とアドオンの 'component.js'のように、どのように組み込みますか?第二に、コンポーネントが 'tests'と' app'で定義されている場合、これはデフォルトになっていますか? (質問は編集1に更新されました) – shane

+1

あなたの 'component.js'から' layout'をインポートしますか?あなたはテンプレートをインポートしていないようです。 [このアドオン](https://github.com/tubitak-bilgemyy/ember-contextual-table)をご覧ください。それは統合テストを持っています。 – ykaragol

+0

'import template from './template'を追加しようとしました。 &layout:残念ながら、addon/components/my-component/component.jsのテンプレートを使用する前に – shane

関連する問題