Aurelia Testing Composed Custom Element

孤街浪徒 提交于 2019-12-11 05:46:15

问题


Unit testing question: When I test a component as per aurelia.io example,

...
component = StageComponent
  .withResources('components/comp/comp')
  .inView('<comp data.bind="info"></comp>')
  .boundTo({info: data});
...

I can query document and check attribute values of DOM nodes.

const nameElement = document.getElementById('elem-id');

When I try testing a composed element,

...
component = StageComponent
  .withResources('components/elemy/elemy')
  .inView('<compose view.bind="components/elemy/elemy.html" '+
        'view-model="components/elemy/elemy" model.bind="info">       </compose>')
  .boundTo({info: data});
...

I can see them in browser running Karma during testing and if I inspect, I see 'info' got passed in correctly to the custom element. But document queries return null:

const nameElement = document.getElementById('elem-id');

Am I missing something obvious? Reason why I want to test with compose is because that's how I use the custom element. It has no @bindable, only activate(model)

来源:https://stackoverflow.com/questions/40371098/aurelia-testing-composed-custom-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!