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
ember如何确定{{my-component}}
在哪里?
这有点像这个:
How does Ember-CLI precompile templates?
编辑 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>
按照惯例。
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';
这是 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?
编辑 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>
按照惯例。
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';