title: How to Unit Test a Directive In Angular 2?
body: <p><strong>Problem:</strong> I would like to be able to <em>unit test a directive in Angular 2 to make sure that it properly compiles.</em> </p>
  
  <p>In Angular 1, it was possible to use<code>$compile(angular.element(myElement)</code> service and call <code>$scope.$digest()</code> after that. I specifically want to be able to do this in unit tests so I could test that when Angular ends up running across <code>&lt;div my-attr-directive/&gt;</code> in the code that <code>my-attr-directive</code> compiles. </p>
  
  <p><strong>Constraints:</strong></p>
  
  <ul>
  <li><strong>Angular 2 using JAVASCRIPT</strong>. All sources somewhat related seem to require TS. <a href="https://medium.com/google-developer-experts/angular-2-unit-testing-with-jasmine-defe20421584#.m2kperx0x" rel="noreferrer">Perhaps this resource truly does solve the problem</a> and my understanding of TS is just that weak</li>
  <li><strong>Unit Test in Jasmine</strong></li>
  <li>Must be not be so hacky that my unit tests will eventually break. See <a href="https://stackoverflow.com/questions/34807798/how-to-compile-html-in-angular-2" title="a related SO post on compiling HTML manually in Angular 2">a related SO post on compiling HTML manually in Angular 2</a></li>
  </ul>