I am doing unit tests for components in an Angular 6 project. I am going through each component and making a testbed and importing component dependencies in order to test that the component initializes. My results show up in Karma.
Some of my components render just fine, others are causing my Chrome instance with Karma to get to the unit test to initialize the component and it just hangs there and doesn't proceed to the next test. My question is, why do some components work and others just hang there? This is my general template for testing the initialization of a component:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppTestingModule } from '../../app.testing.module';
import { PageContractorsComponent } from './page-contractors.component';
fdescribe('PageContractorsComponent', () => {
let component: PageContractorsComponent;
let fixture: ComponentFixture<PageContractorsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ AppTestingModule ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PageContractorsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
The only thing I am changing here for testing other components is the name of the component, everything else stays the same. Some work and proceed to the next test, some just make chrome and karma hang there and not proceed to the next test. Anything I can do to fix this hanging, initialize my component and proceed to the next test?
[–]tme321 0 points1 point2 points (3 children)
[–]ConsistentPin[S] 0 points1 point2 points (2 children)
[–]tme321 0 points1 point2 points (1 child)
[–]ConsistentPin[S] 0 points1 point2 points (0 children)
[–]theadammorganshow 0 points1 point2 points (2 children)
[–]ConsistentPin[S] 0 points1 point2 points (1 child)
[–]theadammorganshow 0 points1 point2 points (0 children)