Ionic2: including Ionic push breaks E2E testing

I have a weird situation where I include Ionic Push in my app.module.ts, none of my E2E tests will run. The test does not start with a timeout error. It would seem somehow Push does not allow the browser to return .waitForAngular ().

Example 1 - E2E doesn't work:

import {CloudModule, CloudSettings, Push} from "@ionic/cloud-angular";

@NgModule({
    providers: [
        // my other providers ...
        { provide: MyPushService, useClass: MyPushService, deps: [Push] }
    ]

      

Example 2: add mock class, E2E works:

import {CloudModule, CloudSettings, Push} from "@ionic/cloud-angular";

@NgModule({
    providers: [
        // my other providers ...
        { provide: Push, useClass: PushMock},
        { provide: MyPushService, useClass: MyPushService, deps: [Push] }
    ]

      

I have been looking at the push.js source hoping to find setTimeout, setInterval or something similar that might make angular think it is waiting for something, but I can't see anything.

Any help is greatly appreciated.

+3


source to share


1 answer


Hacked workaround:

 {provide: Push, useClass: window['cordova'] ? Push : PushMock}

      



This way it will only use the real Push class when running on a device.

0


source







All Articles