webdriverio-community / wdio-vscode-service

A service to test VSCode extensions from end to end using WebdriverIO
https://webdriverio-community.github.io/wdio-vscode-service/
MIT License
29 stars 23 forks source link

Unexpected "Connection closed" when runing with @wdio/cucumber-framework #115

Closed seanpoulter closed 5 months ago

seanpoulter commented 5 months ago

Problem

When I use @wdio/cucumber-framework to run my tests Then I see an unexpected Error: Connection closed. Code: 1006

> wdio run ./test/wdio.conf.ts

Execution of 1 workers started at 2024-02-26T22:11:39.549Z

Skipping download, bundle for ChromeDriver v27.2.3 already exists
Found existing install in .../.wdio-vscode-service/vscode-linux-arm64-1.86.2. Skipping download

[0-0] RUNNING in chrome - file:///test/features/webview.feature
[0-0] file:///.../node_modules/wdio-vscode-service/src/service.ts:60
[0-0]         this._promisedSocket = Promise.reject(new Error(msg))
[0-0]                                               ^
[0-0] Error: Connection closed. Code: 1006, reason: 
[0-0]     at VSCodeWorkerService._handleSocketClose (file:///.../node_modules/wdio-vscode-service/src/service.ts:60:47)
[0-0]     at Object.onceWrapper (node:events:629:26)
[0-0]     at WebSocket.emit (node:events:526:35)
[0-0]     at WebSocket.emit (node:domain:488:12)
[0-0]     at WebSocket.emitClose (.../node_modules/wdio-vscode-service/node_modules/ws/lib/websocket.js:265:10)
[0-0]     at Socket.socketOnClose (.../node_modules/wdio-vscode-service/node_modules/ws/lib/websocket.js:1289:15)
[0-0]     at Socket.emit (node:events:514:28)
[0-0]     at Socket.emit (node:domain:488:12)
[0-0]     at TCP.<anonymous> (node:net:337:12)
[0-0] FAILED in chrome - file:///test/features/webview.feature

Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:08  

Steps to Reproduce

I've reproduced the error from a private repo in https://github.com/seanpoulter/wdio-vscode-cucumber-example:

nvm install --lts
nvm use --lts
npm ci
npm run test

Analysis

The error is thrown from line 60 https://github.com/webdriverio-community/wdio-vscode-service/blob/92b7b6b8ba8def19eb446cae7a1f9107150caffb/src/service.ts#L58-L62

which is registered on line 116

https://github.com/webdriverio-community/wdio-vscode-service/blob/92b7b6b8ba8def19eb446cae7a1f9107150caffb/src/service.ts#L110-L117

Questions

christian-bromann commented 5 months ago

I wonder how the Cucumber execution differs from e.g. Mocha that causes this problem is the first place 🤔

seanpoulter commented 5 months ago

Let me know if you want me to dig into it.

christian-bromann commented 5 months ago

I think we can move forward with the patch #116 .. it's not to crucial for me to get to the bottom of this as long as we document what we are doing in #116 so everyone knows.