这是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}}
的位置?
这与此一脉相承:
How does Ember-CLI precompile templates?
根据评论,我通过导入/导出常规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>
答案 0 :(得分:2)
按惯例。
Ember尝试在my-component
目录或app/components
目录或app/components/templates
目录下找到名为app/helpers
的文件。
如果您在my-component
目录下定义addon/components
,则需要在app/components
目录或tests/dummy/app/components
目录下重新定义,例如:
export { default } from 'my-addon/components/my-component';