【问题标题】:Setting app permissions for Detox iOS tests not working properly为 Detox iOS 测试设置应用程序权限无法正常工作
【发布时间】:2021-03-04 01:13:58
【问题描述】:

我在使用 Detox 中设置 iOS 权限的这种方法和其他方法时遇到问题。我的应用程序最初将通过通知弹出窗口启动,然后如果我关闭弹出窗口,应用程序将在没有通知的情况下重新启动,但仍需要手动干预。我在 init.js 中的代码是:

beforeAll(async () => {
  await detox.init(undefined, { launchApp: false });
  await device.launchApp({ permissions: { notifications: 'YES' } });
});

我还尝试了在此线程中找到的替代方法,产生相同的结果:https://github.com/wix/Detox/pull/2009

【问题讨论】:

  • 您是否安装了applesimutils
  • 是的,我愿意。我们已经通过在我链接的 github 线程中找到的方法组合解决了这个问题。谢谢
  • 您应该添加一个您所做的答案,并将其标记为已解决。
  • 您能分享一下您的解决方案吗?

标签: jestjs react-native-ios detox


【解决方案1】:

在这里找到解决方法:

https://github.com/wix/Detox/pull/2009#issuecomment-648971528

有了这个与 jest-circus 的新集成。我应该如何使用我需要的权限启动应用程序?

我通过覆盖我的 CustomDetoxEnvironment 中的 initDetox 函数来再次进行测试,如下所示:

async initDetox() {
    const instance = await this.detox.init(undefined, {launchApp: false});
    await instance.device.launchApp({permissions: {notifications: 'YES'}});
    return instance;
  }

这最终对我有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 2020-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    相关资源
    最近更新 更多