app.component.spec.ts raw

   1  import { TestBed } from '@angular/core/testing';
   2  import { AppComponent } from './app.component';
   3  
   4  describe('AppComponent', () => {
   5    beforeEach(async () => {
   6      await TestBed.configureTestingModule({
   7        imports: [AppComponent],
   8      }).compileComponents();
   9    });
  10  
  11    it('should create the app', () => {
  12      const fixture = TestBed.createComponent(AppComponent);
  13      const app = fixture.componentInstance;
  14      expect(app).toBeTruthy();
  15    });
  16  
  17    it(`should have the 'firefox' title`, () => {
  18      const fixture = TestBed.createComponent(AppComponent);
  19      const app = fixture.componentInstance;
  20      expect(app.title).toEqual('firefox');
  21    });
  22  
  23    it('should render title', () => {
  24      const fixture = TestBed.createComponent(AppComponent);
  25      fixture.detectChanges();
  26      const compiled = fixture.nativeElement as HTMLElement;
  27      expect(compiled.querySelector('h1')?.textContent).toContain('Hello, firefox');
  28    });
  29  });
  30