title: Testing code that uses document.body.querySelectorAll
body: <p>Trying to test a directive that does the following:</p>
  
  <pre><code>var inputs = angular.element(document.body.querySelectorAll('input[ng-model]', elem));
  // [code relying on found elements]
  </code></pre>
  
  <p>Running inside karma/jasmine/phantomjs, this fails because it seems that <code>document</code> returns the document that contains the test, rather than the compiled template. Is there some way to mock this functionality so it works as expected (for my use case) or some other way to query for those elements?</p>
  
  <p>PS: The elements that need to be located are in no known relation to the element that the directive is applied to.</p>