我不断收到此错误,并且已经遍历文档和各种线程,无法弄清楚为什么会发生这些错误,因为它们毫无意义。
我的规格配置有1个简单测试:
describe('AddVideoComponent', () => {
let component: AddVideoComponent;
let fixture: ComponentFixture<AddVideoComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ReactiveFormsModule,
HttpClientModule,
MatSnackBarModule,
FormsModule
],
declarations: [AddVideoComponent, CleanLinkPipe],
providers: [RestService, NgRedux, AdalService],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AddVideoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
}));
it('should create form group with 5 controls', () => {
component.ngOnInit();
fixture.detectChanges();
expect(component.addVideoForm.contains('title')).toBeTruthy();
});
});
我遇到的错误:
Failed: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
+
TypeError: Cannot read property 'ngOnInit' of undefined
现在在我的组件中,我没有以任何方式订阅任何东西,没有任何类型的订阅。