マイcomponent.tsファイルがJamineユニット・テスト・エラーが
import { Component, OnInit } from '@angular/core';
import { select } from 'ng2-redux';
import { Observable } from 'rxjs/Observable';
import { PersonalDetailsComponent } from '../personal-details/personal-details.component'
@Component({
selector: 'app-profile-details',
templateUrl: './profile-details.component.html'
})
export class ProfileDetailsComponent implements OnInit {
@select(['customerData', 'personalDetails'])personalDetails:Observable<object>; //<------if i comment out @select statement, then the tests work
@select(['loading']) loading: Observable<boolean>;//<------if i comment out @select statement, then the tests work
constructor() { }
ngOnInit() { }
}
以下のようになります。そして、私のジャスミンのテストは、この
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NgRedux, select } from 'ng2-redux';
import { ProfileDetailsComponent } from './profile-details.component';
import { customerData } from '../data/customerProfileDataMock';
import { PersonalDetailsComponent } from '../personal-details/personal-details.component'
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
class RouterStub { navigate(params) { } }
class MockSelect { }
class MockObservable<T> {}
class NgReduxStub {
constructor() { }
dispatch =() => undefined;
getState =() => { return customerData; };
subscribe =() => undefined;
}
describe('ProfileDetailsComponent',() => {
let component: ProfileDetailsComponent;
let fixture: ComponentFixture<ProfileDetailsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ProfileDetailsComponent, PersonalDetailsComponent],
providers: [
{ provide: Router, useClass: RouterStub },
{ provide: select, useClass: MockSelect },
{ provide: NgRedux, useClass: NgReduxStub },
{ provide: Observable, useClass: MockObservable }
],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ProfileDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the profile details page',() => {
expect(component).toBeTruthy();
});
});
ないいただきまし不足していることを確認のように見えますが、@ select文は嘲笑し、私はあなたの場合は、コマンド「NGテスト」
TypeError: ng_redux_1.NgRedux.instance is undefined in src/test.ts