对 2 个测试文件运行“排毒测试”时出现“错误:无法连接”

问题描述

我已经在我的 React Native 项目上安装了 Detox,它似乎运行良好,直到我添加了第二个测试文件。显然,在运行第一个文件的测试后,它出于某些原因更改了侦听端口,因此无法连接到新设备

这是我的文件和终端日志:

终端日志

detox[59310] INFO:  [DetoxServer.js] server listening on localhost:51515...
detox[59310] INFO:  Example is assigned to emulator-11304 (Pixel_API_29_AOSP)
detox[59310] INFO:  Example: should show hello screen after tap
detox[59310] INFO:  Example: should show hello screen after tap [OK]

 PASS  e2e/test.spec.js (14.63 s)
  Example
    ✓ should show hello screen after tap (833 ms)

detox[59310] INFO:  [DetoxServer.js] server listening on localhost:51603...
detox[59310] ERROR: [EmulatorTelnet.js/TELNET_ERROR] 
  err: Cannot connect
detox[59310] ERROR: Error: Cannot connect
detox[59310] INFO:  E is assigned to undefined
detox[59310] INFO:  E: qwe
detox[59310] INFO:  E: qwe [SKIPPED]

detox[59310] ERROR: [EmulatorTelnet.js/TELNET_ERROR] connect ECONNREFUSED 127.0.0.1:23
  err: Error: connect ECONNREFUSED 127.0.0.1:23
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
detox[59310] ERROR: Error: connect ECONNREFUSED 127.0.0.1:23
detox[59310] WARN:  at node_modules/jest/node_modules/jest-cli/build/cli/index.js:261:15 
 Jest did not exit one second after the test run has completed.

e2e/test.e2e.js(第一个测试文件

describe('Example',() => {
  beforeAll(async () => {
    await device.launchApp();
  });

  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should show hello screen after tap',async () => {
    await expect(element(by.text('AVC Diag'))).toBeVisible();
  });
});

e2e/test2.e2e.js(第二个测试文件

describe('E',() => {
    beforeAll(async () => {
      await device.launchApp();
    });
  
    beforeEach(async () => {
      await device.reloadReactNative();
    });
  
    it('qwe',async () => {
      await expect(element(by.text('AVC Diag'))).toBeVisible();
    });
  });

e2e/config.json

{
    "testEnvironment": "./environment","testRunner": "jest-circus/runner","testTimeout": 120000,"testRegex": "\\.e2e\\.js$","reporters": ["detox/runners/jest/streamlineReporter"],"verbose": true
}

谁能帮我解决这个问题?使用我最好的朋友谷歌没有找到任何线索...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)