【问题标题】:Detox: Waiting for network requests to finish timeout排毒:等待网络请求完成超时
【发布时间】:2020-01-06 05:41:26
【问题描述】:

我正在尝试设置 detox 在我的应用程序上运行 e2e 测试(react native + expokit)。 正如我在https://github.com/wix/Detox/issues/1627 中提到的,我的测试一直超时

Waiting for network requests to finish.: (
    "http://10.4.12.38:19001/symbolicate",
    "http://10.4.12.38:19001/symbolicate",
    "http://10.4.12.38:19001/symbolicate",
    "http://10.4.12.38:19001/symbolicate",
    "http://10.4.12.38:19001/onchange"
)

我已将这些网址添加到detoxURLBlacklistRegex,但它并不能解决问题。正如我在https://github.com/wix/Detox/issues/1627 中所说的,我认为禁用实时重新加载会使测试通过,但并非总是 如此——有时会,有时会超时。这是我的init.js

const detox = require('detox');
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');

const config = require('../package.json').detox;

// Set the default timeout
jest.setTimeout(30000);
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);

beforeAll(async () => {
  await detox.init(config, {
    launchApp: false,
  });
  await device.launchApp({
    permissions: { notifications: 'YES' },
    launchArgs: {
      detoxPrintBusyIdleResources: 'YES',
      detoxURLBlacklistRegex:
        '.*://10.4.12.38.*',
    },
  });
});

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

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

这个问题可以在这个 repo 中重现:https://github.com/clems36/detox-test

这是踪迹:

detox[55327] TRACE: [Detox.js/DETOX_BEFORE_EACH] running test: "Example should show hello screen after tap"
detox[55327] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeEach({
  title: 'should show hello screen after tap',
  fullName: 'Example should show hello screen after tap',
  status: 'running'
})
detox[55327] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"reactNativeReload","params":{},"messageId":-1000}
detox[55327] TRACE: [DetoxServer.js/MESSAGE] role=tester action=reactNativeReload (sessionId=6ee3a6df-152d-a069-f95a-ecd53e7fc872)
detox[55327] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"hello_button"}]}}]}},"method":"performAction:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYActions"},"method":"actionForTap","args":[]}}]},"messageId":2}
detox[55327] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=6ee3a6df-152d-a069-f95a-ecd53e7fc872)
Example: should show hello screen after tap [FAIL]
Example: should show world screen after tap
detox[55327] TRACE: [Detox.js/DETOX_AFTER_EACH] failed test: "Example should show hello screen after tap"
detox[55327] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterEach({
  title: 'should show hello screen after tap',
  fullName: 'Example should show hello screen after tap',
  status: 'failed',
  timedOut: true
})
detox[55327] WARN:  [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
  (id = 2) invoke: {"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"hello_button"}]}}]}},"method":"performAction:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYActions"},"method":"actionForTap","args":[]}}]}
  (id = -1000) reactNativeReload: {}

That might be the reason why the test "Example should show hello screen after tap" has timed out.

【问题讨论】:

  • 你解决了吗?我也有同样的问题。

标签: react-native testing expo end-to-end detox


【解决方案1】:

您是否尝试过转义特殊字符?它在 detox docs 中说,我们可以通过提供 正则表达式 来跳过某些 URL,从而在首选端点上禁用 EarlGrey's network synchronization mechanism 机制。

例如,

  beforeAll(async () => {
    await device.setURLBlacklist([
      '.*10\.4\.12\.38.*'
    ]);
  });

至少对我来说是这样 - 如果可行,请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多