import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MyComponent } from './my.component';
describe('MyComponent', () => {
let fixture: ComponentFixture<MyComponent>;
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [MyComponent] }).compileComponents();
fixture = TestBed.createComponent(MyComponent);
});
it('should display title', () => {
fixture.componentInstance.title = 'Hello';
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Hello');
});
});This test creates the component, sets a title, triggers Angular change detection, and checks if the title appears in the template.