title: How to access the DOM Element in an aurelia unit test?
body: <p>In a unit test, how can I instantiate a custom element (or view) and get access to the <em>live</em> DOM element?</p>
  
  <p>I read <a href="http://patrickwalters.net/unit-testing-your-es6-view-models-my-best-practices-for-aurelia/" rel="nofollow noreferrer">this article</a> which gets to the point where the custom element is instantiated but I don't think I can get to the DOM element.</p>
  
  <p>BTW, I know about Protractor and end-to-end testing but that's not what I'm looking for here.</p>
  
  <hr>
  
  <p><strong>Update Oct 14 2016:</strong></p>
  
  <p>I found out that I can register an instance like this to make the <code>@inject(Element)</code> work:</p>
  
  <pre><code>container = new Container().makeGlobal();
  container.registerInstance(Element, document.createElement('div') );
  vm = BehaviorInstance.createForUnitTest(Test, {}, {});
  </code></pre>
  
  <p>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 <code>innerHtml</code> is <code>&lt;div&gt;&lt;/div&gt;</code>.</p>