关于离子3中的标签,我在每次测试(成功或失败)结束时都有错误。
它似乎来自我的tabs.html中的<ion-tabs></ion-tabs>
元素,因为当我评论它时,错误就消失了。
我也无法在我的测试中使用fixture.destroy();
它显示此错误:
TypeError:无法读取属性&#39; unregisterChildNav&#39;为null
只有离子生成的基本项目选项卡,通过此命令:ionic start myApp tabs
我刚刚添加了标签的规范。
如果有帮助,下面是我的规范代码:
import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { MyApp } from '../../app/app.component'; import { TabsPage } from './tabs';
// import { ViewControllerMock } from '../../mocks';
let comp: TabsPage;
let fixture: ComponentFixture<TabsPage>;
let de: DebugElement;
let deArray: DebugElement[];
let el: HTMLElement;
describe('Page: Tabs', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [MyApp, TabsPage],
providers: [
],
imports: [
IonicModule.forRoot(MyApp)
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TabsPage);
comp = fixture.componentInstance;
// fixture.detectChanges();
});
afterEach(() => {
// fixture.destroy();
comp = null;
de = null;
el = null; });
it('should be created', () => {
expect(fixture).toBeTruthy();
expect(comp).toBeTruthy();
});
it ('should have 4 tabs', () => {
deArray = fixture.debugElement.queryAll(By.css('ion-tabs ion-tab'));
expect(deArray.length).toBe(4);
});
});
希望有人可以帮助我:)。