java.net.ConnectException: 连接被拒绝:在 webdriverio v7 测试中抛出连接错误

java.net.ConnectException: Connection refused: connect error thrown in the middle of the webdriverio v7 test

我正在使用 webdriverIO v7 和 cucumber 来测试我的应用程序。
我有包含 10 个场景的功能文件。
发生的事情是,当我 运行 测试时,前 4 个场景无缝执行,在第五个场景中突然出现错误:

unknown error: java.net.ConnectException: Connection refused: connect
    at Object.getErrorFromResponseBody (C:\my-project\node_modules\webdriver\build\utils.js:189:12)
    at WebDriverRequest._request (C:\my-project\node_modules\webdriver\build\request.js:168:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Browser.runCommandWithHooks (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:105:25)
    at Browser.runCommandWithHooks (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:100:24)
    at Browser.url (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:67:44)
    at MyPage.openImportPage (C:\my-project\src\pages\/myPage.js:32:17)
    at forEach (C:\my-project\src\helpers\/helpers.js:60:21)
    at Array.forEach (<anonymous>)
    at Helpers.deleteWishLists (C:\my-project\src\helpers\/helpers.js:55:51)
    at World.<anonymous> (C:\my-project\src\step_definitions\/config_steps.js:28:13)
    at World.executeSync (C:\my-project\node_modules\@wdio\sync\build\index.js:38:22)
    at World.executeSync (C:\my-project\node_modules\@wdio\sync\build\index.js:52:38)
    at C:\my-project\node_modules\@wdio\sync\build\index.js:69:68

第五个场景的第一步,在之前的场景中也执行过,正常成功。
它的行为不一致 - 例如,当 运行 第二次在非无头模式下所有场景都通过(突然)。
运行 在 headless 模式下,有时所有场景都会因该异常而失败,有时只有一些失败 - 没有规则需要注意。
这是非常混乱的。我认为这与我的测试无关,因为有时它们都通过了,但与我的设置或互联网连接或 webdriverIO 框架及其独立模式有关...
有没有人知道为什么会这样。谁是这里的麻烦制造者?
我什至不知道我应该从哪个方向去调查这个。
请帮忙。
谢谢!

最终问题出在我的互联网连接上。
wdio 的人为它做了一个小补丁:
https://github.com/webdriverio/webdriverio/issues/6728