title: Mock the <ng-template> for unit test - Angular 2
body: <p>I need to be able to mock angular's <code>ng-template</code> for a unit test. When I try to run it I get this error:</p>
  
  <pre><code>Components on an embedded template: NgTemplateStub ("
  &lt;grid-column&gt;
      [ERROR -&gt;]&lt;ng-template gridCellTemplate dataItem&gt;
          &lt;custom-column-template [data]="dataItem"&gt;&lt;/custom-column-template&gt;
      &lt;/ng-template&gt;
  &lt;grid-column&gt;
  ")
  </code></pre>
  
  <p>Here is my mock verson of <code>ng-template</code></p>
  
  <pre><code>@Component({
    selector: "ng-template",
    template: "&lt;div&gt;&lt;ng-content&gt;&lt;/ng-content&gt;&lt;/div&gt;",
  })
  export class NgTemplateStub {}
  </code></pre>
  
  <p>Here is the actual template I am trying to mock</p>
  
  <pre><code> &lt;grid [data]="form$ | async" [pageSize]="pageSize"&gt;
       &lt;grid-column width="50"&gt;
          &lt;ng-template gridCellTemplate dataItem&gt;
             &lt;custom-column [dataItem]="dataItem"&gt;&lt;/custom-column&gt;
          &lt;/ng-template&gt;
       &lt;/grid-column&gt;
       &lt;!-- other columns --&gt; 
   &lt;/grid&gt;
  </code></pre>
  
  <p>Here is the TestModule</p>
  
  <pre><code> fixture = TestBed.configureTestingModule({
      declarations: [
          ...
          FormsGridComponent,
          NgTemplateStub,
      ],
      imports: [
          ...
      ],
      providers: [
          ...
      ],
  }).createComponent(GridComponent)
  </code></pre>
  
  <p>Is it possible to mock <code>ng-template</code>?</p>