Ionic 4 + angular 8 test failure

I encountered the issue as well but with Jest, here is my solution :

let statusBarSpy;
  let splashScreenSpy;
  let platformReadySpy: Promise<void>;
  let platformSpy;

  beforeEach(async(() => {
    statusBarSpy = { styleDefault: jest.fn() };
    splashScreenSpy = { hide: jest.fn() };
    platformReadySpy = Promise.resolve();
    platformSpy = {
      ready: jest.fn().mockReturnValue(platformReadySpy),
      backButton: { subscribeWithPriority: jest.fn() },
      is: jest.fn().mockReturnValue(true)
    };

    TestBed.configureTestingModule({
      declarations: [AppComponent],
      imports: [IonicModule, RouterTestingModule],
      providers: [
        { provide: StatusBar, useValue: statusBarSpy },
        { provide: SplashScreen, useValue: splashScreenSpy },
        { provide: Platform, useValue: platformSpy }
      ]
    }).compileComponents();
  }));
1 Like