title: Getting "Expected undefined to be truthy." when testing to see if Componet is create
body: <p>As part of expanding and updating my Skill set. I have been assigned to write Jasmine/Karma tests for an Angular 9 application. I have completed an online tutorial and done some Google searches.  I started writing my first unguided test cases and I am running into something I have not yet found a way past.</p>
  <p>My HTML is this:</p>
  <pre><code>&lt;div class=&quot;container-fluid&quot;&gt;
  &lt;div class=&quot;center&quot;&gt;
    &lt;div class=&quot;welcome-container&quot;&gt;
      &lt;div class=&quot;title&quot;&gt;PCPlan&lt;/div&gt;
    &lt;/div&gt;
    &lt;mat-card&gt;
      &lt;div class=&quot;login-form&quot;&gt;
        &lt;div class=&quot;inputs&quot;&gt;
          &lt;mat-form-field class=&quot;formfield-min-width&quot;&gt;
            &lt;input matInput type=&quot;text&quot; placeholder=&quot;AD Username&quot; [(ngModel)]=&quot;model.username&quot; (keyup.enter)=&quot;login()&quot; tabindex=&quot;0&quot; autofocus=&quot;true&quot;/&gt;
            &lt;button mat-button *ngIf=&quot;model.username&quot; matSuffix mat-icon-button aria-label=&quot;username&quot; (click)=&quot;model.username=''&quot; tabindex=&quot;-1&quot;&gt;
              &lt;i class=&quot;fas fa-times-circle&quot;&gt;&lt;/i&gt;
            &lt;/button&gt;
          &lt;/mat-form-field&gt;
  
          &lt;mat-form-field class=&quot;formfield-min-width&quot;&gt;
            &lt;input matInput type=&quot;password&quot; placeholder=&quot;Password&quot; [(ngModel)]=&quot;model.password&quot; (keyup.enter)=&quot;login()&quot; tabindex=&quot;0&quot; autofocus=&quot;true&quot;/&gt;
            &lt;button mat-button *ngIf=&quot;model.password&quot; matSuffix mat-icon-button aria-label=&quot;password&quot; (click)=&quot;model.password=''&quot; tabindex=&quot;-1&quot;&gt;
              &lt;i class=&quot;fas fa-times-circle&quot;&gt;&lt;/i&gt;
            &lt;/button&gt;
          &lt;/mat-form-field&gt;
        &lt;/div&gt;
  
        &lt;button mat-raised-button color=&quot;primary&quot; (click)=&quot;login()&quot; class=&quot;login-button&quot;&gt;LOG IN&lt;/button&gt;
  
        &lt;div&gt;
          &lt;div *ngIf=&quot;errMsg&quot; style=&quot;color:indianred; font-weight: bold&quot;&gt;{{errMsg}}&lt;/div&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
    &lt;/mat-card&gt;
  &lt;/div&gt;
  </code></pre>
    
  <p>My .ts file is:</p>
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Router } from '@angular/router';
  import { AuthGuard } from 'src/app/routing/guards/auth.guard';
  import { AuthenticationService } from 'src/app/services/shared/authentication.service';
  import { LoginService } from 'src/app/services/shared/login.service';
  //import { UserAPI } from 'src/app/services/api/userAPI.service';
  import { take } from 'rxjs/operators';
  import { authBaseUrl, pcplanServiceBaseUrl } from 'src/environments/environment';
  //import { MatToolbarModule, MatIconModule, MatFormFieldModule, MatCardModule, MatInputModule, MatButtonModule } from '@angular/material';
  import { FormsModule } from '@angular/forms';
  import { CdkTableModule} from '@angular/cdk/table';
  import {DataSource} from '@angular/cdk/table';
  
  @Component({
    selector: 'app-login',
    templateUrl: './login.component.html',
    styleUrls: ['./login.component.scss'],
  })
  
  export class LoginComponent implements OnInit {
    model: any = {
      username: '',
      password: '',
    };
    errMsg = '';
    constructor(
      private router: Router,
      private loginService: LoginService,
      private authenticationService: AuthenticationService,
     // public userAPI: UserAPI,
      public Authinacate: AuthGuard,
      private http: HttpClient,
    ) { }
    userInfo = this.authenticationService.getUserInfo();
    userInTestTableValue = '';
    userAccessChecked = false;
  
    ngOnInit() {
      // reset login status
      console.log(&quot;Initializing: login.component.ts&quot;)
  
  
      this.loginService.logout();
    }
  
    login() {
      this.loginService.getToken(this.model.username, this.model.password)
        .subscribe(resp =&gt; {
          if (!resp.user || resp.user.token === 'INVALID') {
            console.log(&quot;:(&quot;);
            if (!Array.isArray(resp)) {
              this.errMsg = 'Username or password is incorrect ';
            }
            return;
          } 
          else {
            console.log('success')
            this.router.navigate([resp.landingPage]);
          }
        },
          errResponse =&gt; {
            switch (errResponse.status) {
              case 401:
                this.errMsg = 'Username or password is incorrect';
                console.log(this.errMsg);
                break;
              case 404:
                this.errMsg = 'Service not found';
                break;
              case 408:
                this.errMsg = 'Request Timedout';
                break;
              case 500:
                this.errMsg = 'Internal Server Error';
                break;
              default:
                this.errMsg = 'Login failed: Make sure Username and Password are correct and try again.';
            }
          }
        );
    }
  
    onSignUp() {
      this.router.navigate(['signup']);
    }
  }
  
  </code></pre>
  <p>and my spec file is:</p>
  <pre><code>import { ComponentFixture, TestBed } from &quot;@angular/core/testing&quot;
  import { LoginComponent } from './login.component'
  
  describe('Login Component', () =&gt; {
      let fixture: ComponentFixture&lt;LoginComponent&gt;;
  
      beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              declarations: [LoginComponent],
          });
          fixture = TestBed.createComponent(LoginComponent);
      });
  
      it('Component successfully created', () =&gt; {
          expect(fixture).toBeTruthy();
      });
  })
  </code></pre>
  <p>My suspicion is that there is something simple that I am missing, but I can't get this test to run and the result I am getting &quot;Expected undefined to be truthy.&quot;</p>
  <p>I believe the fixture is defined.</p>