3

I have an error at the end of each of my test (successed or failed) concerning tabs in ionic 3.

It seems that it come from the <ion-tabs></ion-tabs> element in my tabs.html, because when I commented it, the error desappeared.

I also can't use fixture.destroy(); in my test it shows this error:

TypeError: Cannot read property 'unregisterChildNav' of null

There's nothing more than the generated basic project tabs from ionic, by this command: ionic start myApp tabs

I've just added the spec for the tabs.

If it could help, below is the code of my spec:

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);

  });
});

Hope someone could help me :)

Nicolas
  • 2,684
  • 1
  • 16
  • 22

0 Answers0