【问题标题】:Ionic2: Including Ionic Push breaks E2E testingIonic2:包括 Ionic Push 中断 E2E 测试
【发布时间】:2017-07-25 07:45:34
【问题描述】:

我有一个奇怪的情况,如果我在我的 app.module.ts 中包含 Ionic 的 Push,我的 E2E 测试将不会运行。测试因超时错误而无法启动。似乎 Push 以某种方式阻止 browser.waitForAngular() 返回。

示例 1 - E2E 不起作用:

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

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

示例 2 - 添加一个模拟类,E2E 确实有效:

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

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

我一直在查看 push.js 源代码,希望找到一个 setTimeout、setInterval 或类似的东西,这可能会让 angular 认为它正在等待某些东西,但我什么都看不到。

非常感谢任何帮助。

【问题讨论】:

  • 我们面临着完全相同的问题。您是否设法找到解决方案或解决方法?

标签: angular push-notification ionic2 angularjs-e2e


【解决方案1】:

一个 hacky 解决方法:

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

这样在设备上运行时才会使用真正的Push类。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 2017-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多