排毒实例尚未初始化

时间:2020-07-07 00:24:40

标签: react-native detox

遇到以下问题:

detox[35707] INFO:  [test.js] node_modules/.bin/mocha --config e2e/.mocharc.json --configuration ios.sim.release --loglevel verbose --invert --grep :android: --use-custom-logger "true" e2e


detox[35708] INFO:  [DetoxServer.js] server listening on localhost:49779...
DetoxRuntimeError: Detox instance has not been initialized

HINT: There was an error on attempt to call detox.init()

当我打开本地主机端口时,会从控制台获得一个提示:

Failed to load resource: the server responded with a status of 426 (Upgrade Required)

我尝试构建调试版本,两者都相同,浏览了所有堆栈溢出但没有帮助。

Package.json:

"detox": "^17.1.0",
"react-native": "^0.58.6",
"jasmine": "^3.5.0",

Init.js:

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");

// Set the default timeout
jest.setTimeout(300000);

jasmine.getEnv().addReporter(adapter);

// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);

// This will post which device has assigned to run a suite, which can be useful in a multiple-worker tests run.
// This is strictly optional.
jasmine.getEnv().addReporter(assignReporter);

beforeAll(async () => {
  await detox.init(config);
});

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

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

0 个答案:

没有答案