1

这是 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  

ember 如何确定在哪里{{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>
4

1 回答 1

2

按照惯例。

my-componentEmber 尝试在您的app/components目录或app/components/templates目录或目录下找到一个名为的文件app/helpers

如果my-component在你的目录下定义,则需要在你的目录或目录addon/components下重新定义如:app/componentstests/dummy/app/components

export { default } from 'my-addon/components/my-component';
于 2016-08-30T21:01:41.273 回答