我想测试组件如何使用 Parse.initialize(appId,url) 函数在我的Angular Service
?
这是初始化部分:
Parse.initialize('MY_APP_ID', 'JS_KEY');
Parse.serverURL = 'https://parseapi.back4app.com/';
这是我的测试部分:
describe('StateComponent', () => {
let component: StateComponent;
let fixture: ComponentFixture<StateComponent>;
let service: TrayStateService;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [StateComponent],
providers: [
TrayStateService,
{ provide: NbDialogService, useValue: {} },
{ provide: NbToastrService, useValue: {} },
ChangeDetectorRef,
AuthSessionQuery,
{
provide: 'env',
useValue: environment
}
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
service = TestBed.inject(TrayStateService);
}));
beforeEach(() => {
fixture = TestBed.createComponent(StateComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should verify that immediate function works properly', fakeAsync(() => {
spyOn(service, 'getAll').and.returnValue(of(MockedDataResponseArray));
component.ngOnInit();
tick(10);
}));
这是我得到的错误:
错误:您需要在使用 Parse 之前调用 Parse.initialize。