-
- let userServiceStub: Partial;
- beforeEach(() => {
- // stub UserService for test purposes
- userServiceStub = {
- isLoggedIn: true,
- user: { name: 'Test User'}
- };
- TestBed.configureTestingModule({
- declarations: [ WelcomeComponent ],
- providers: [ {provide: UserService, useValue: userServiceStub } ]
- });
- fixture = TestBed.createComponent(WelcomeComponent);
- comp = fixture.componentInstance;
- // UserService from the root injector
- userService = TestBed.get(UserService);
- // get the "welcome" element by CSS selector (e.g., by class name)
- el = fixture.nativeElement.querySelector('.welcome');
- });