问题
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