In a unit test, how can I instantiate a custom element (or view) and get access to the live DOM element?
I read this article which gets to the point where the custom element is instantiated but I don't think I can get to the DOM element.
BTW, I know about Protractor and end-to-end testing but that's not what I'm looking for here.
Update Oct 14 2016:
I found out that I can register an instance like this to make the @inject(Element)
work:
container = new Container().makeGlobal();
container.registerInstance(Element, document.createElement('div') );
vm = BehaviorInstance.createForUnitTest(Test, {}, {});
although the injection works (my Test custom element get the reference), that did not cause aurelia to do anything with the element. My custom element's template has not been used and therefore the element's innerHtml
is <div></div>
.