【问题标题】:DetoxRuntimeError: Detox instance has not been initializedDetoxRuntimeError: Detox 实例尚未初始化
【发布时间】:2020-10-22 15:22:02
【问题描述】:

更新到 react-native 0.63.3 和 xcode 12.0.1 后,测试不再起作用。首先在排毒方面遇到了一些问题,但已经解决了。现在这个错误出现了,我不能再进一步了:

DetoxRuntimeError: Detox instance has not been initialized
HINT: Make sure to call detox.init() before your test begins

detox.init() 正在被调用,我可以在日志中看到它。

这是我的 init.js

import { device } from 'detox';

const detox = require('detox');

const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
const assignReporter = require('detox/runners/jest/assignReporter');

jest.setTimeout(180000);

jasmine.getEnv().addReporter(adapter);

jasmine.getEnv().addReporter(specReporter);

jasmine.getEnv().addReporter(assignReporter);

beforeAll(async () => {
  await detox.init(config, { launchApp: false });
  const permissions = {
    notifications: 'NO',
    camera: 'NO',
  };
  await device.launchApp({ permissions });
});

beforeEach(async () => {
  await adapter.beforeEach();
});

afterAll(async () => {
  await adapter.afterAll();
  await detox.cleanup();
});

我的环境:

React-Native:0.63.3 排毒:17.10.3 xcode:12.0.1 iOS:14.0

在 ios.sim.debug 上运行

【问题讨论】:

    标签: ios react-native detox


    【解决方案1】:

    经过长时间的搜索,我发现实际测试位于项目的子模块/子存储库中。测试是从应用程序根级别触发的。在更新之前,甚至这些测试都被正确触发。现在,它们只有在我将它们从子模块级别移动到应用程序根级别时才有效

    【讨论】:

    • 想详细说明一下?我遇到了类似的问题。那么将应用程序移至根级别是什么意思?哪些文件?谢谢!
    • 对我来说这是一个愚蠢的问题。我们的应用程序结构: -app-root ---->subModule1 ---->subModule2 ---->subModule3 ---->subModule3 ---->subModule4 我们从应用程序根级别触发测试,但是测试适用于该模块中正确文件夹中的每个子模块。错误是我只在应用程序根级别更新了排毒。忘了在子模块上做。在我将一项测试从 subModule 级别移动到 app-root 级别后,测试工作正常。将所有子模块更新到新版本的 detox 后,一切都很好。希望对你有帮助
    猜你喜欢
    • 2020-06-17
    • 2016-07-10
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多