title: Angular 4 Unit Tests Attributes of child components
body: <p>I'm upgrading an Angular 2 app to version 4.0.1, and i'm having troubles with some tests.</p>
  
  <p>I'm trying to get the attributes of a child component and test that the value given is correct.</p>
  
  <p>Unfortunately, the attributes seems to be undefined in the test context, even when the component behave correctly in JiT build and AoT build.</p>
  
  <p>The tests only broke after updating to Angular 4.0.1</p>
  
  <p>Template of my parent component :</p>
  
  <pre><code>&lt;div&gt;
    &lt;div *ngIf="isComponentEnabled"&gt;
      &lt;child-component
        superBaseUrl="super_url" i18n-superBaseUrl="frk|"
        [slug]="slug"
        [name]="name"
        [age]="age"&gt;
      &lt;/child-component&gt;
      .....
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Test that breaks :</p>
  
  <pre><code>     it(`GIVEN parent-component
        THEN it should have correct attribute values`, () =&gt; {
        componentInstance.name = 'Bar';
        componentInstance.age = 90;
        componentInstance.slug = 'foo';
  
        attributes = specService.queryAttributes(
          componentFixture, 'child-component');
  
        console.log('HEYA -&gt; ', specService.queryDebugElement(
          componentFixture, 'child-component'));
        expect(attributes['superbaseurl']).toBe('super_url');
        expect(attributes['i18n-superbaseurl']).toBe('frk|');
        expect(attributes['ng-reflect-slug']).toBe('foo');
        expect(attributes['ng-reflect-name']).toBe('Bar');
        expect(attributes['ng-reflect-age']).toBe('90');
      });
  </code></pre>
  
  <p>Ouput of the breaking test :</p>
  
  <pre><code>Expected undefined to be 'foo'.
  Expected undefined to be 'Bar'.
  Expected undefined to be '90'.
  </code></pre>
  
  <p>Console log inside the test :</p>
  
  <pre><code>&lt;child-component _ngcontent-c115="" i18n-superbaseurl="frk|" superbaseurl="super_url"&gt;
  &lt;/child-component&gt;
  </code></pre>
  
  <p>So i don't understand why in version 4 the attributes are not generated in this context. In version 2.X.X, we had the ng-reflect but it seems that this is no longer the case.</p>
  
  <p>I've also tried to add a basic attribute (toto="toto") in the template, and this one shows up in the console.log of the test.</p>
  
  <p><strong>Does anybody have an idea why the attributes no longer shows up ?</strong></p>
  
  <p>P.S: The specService.queryAttributes is just a wrapper that call detectChanges before querying the attributes.</p>