I am trying to write a unit test for the Login Component of my angular 6 application.
The login.component.ts file has the following constructor
constructor(public global: Globals, private appService: AppService ) {
}
Here Globals is a normal ts file that has some global functions that are used across components. AppService is a service.
My current spec.ts file
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ],
imports:[
FormsModule,
ReactiveFormsModule,
],
providers:[
AppService
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Here component instance is coming as undefined.
Can anyone guide how to create the TestBed configure module for this case and create an instance of the component?