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

Unable to start vscode with wdio runner #91

Closed mikhail-g closed 8 months ago

mikhail-g commented 8 months ago

The installation wizard doesn't produce working code, while the documentation doesn't has a workaround on how to fix it

Environment

OS: macOS Ventura Version 13.5.2 (22G91) node version: 16.16.0

Steps to reproduce:

  1. Clone the repo https://github.com/mikhail-g/wdio-vsce-test-issue or install by running npm create wdio@latest ./ and select the next options: ? What type of testing would you like to do? VS Code Extension Testing https://webdriver.io/docs/vscode-extension-testing ? Which framework do you want to use? Mocha (https://mochajs.org/) ? Do you want to use a compiler? TypeScript (https://www.typescriptlang.org/) ? Do you want WebdriverIO to autogenerate some test files? Yes ? What should be the location of your spec files? /Users/My_User/dev/wdio-vsce-test-issue/test/specs/*/.ts ? Which reporter do you want to use? spec ? Do you want to add a plugin to your test setup? ? Do you want to add a service to your test setup? vscode ? Do you want me to run npm install Yes
  2. run npm i
  3. run npm run wdio

Actual result:

There is an error on Wdio srtart:

ERROR @wdio/config:ConfigParser: Failed loading configuration file: file:///Users/My_User/dev/wdio-vsce-test-issue/wdio.conf.ts: __dirname is not defined in ES module scope
ReferenceError: __dirname is not defined in ES module scope

After fixing it (see 2nd commit) there's another error for which I didn't find a fix or a workaround yet:

wdio run ./wdio.conf.ts

Execution of 1 workers started at ...

INFO @wdio/local-runner: Shutting down spawned worker
INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
INFO @wdio/local-runner: shutting down
Error: Error: Failed to initilialise launcher service unknown: Error: Couldn't initialise "wdio-vscode-service".
TypeError: Cannot destructure property 'URI' of '(intermediate value).default' as it is undefined.
    at file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/wdio-vscode-service/src/server/utils.ts:6:9
    at safeImport (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/utils/build/utils.js:223:15)
    at async initialisePlugin (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/utils/build/initialisePlugin.js:31:20)
    at async initialiseServices (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/utils/build/initialiseServices.js:53:25)
    at async initialiseLauncherService (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/utils/build/initialiseServices.js:81:26)
    at async Launcher.run (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/cli/build/launcher.js:85:65)
    at initialiseLauncherService (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/utils/build/initialiseServices.js:118:15)
    at async Launcher.run (file:///Users/My_User/dev/wdio-vsce-test-issue/node_modules/@wdio/cli/build/launcher.js:85:65)

Expected result:

  1. Wdio has started successfully
  2. The generated example test is running
  3. See the message in console:
> wdio run ./test/wdio.conf.ts

Execution of 1 workers started at ...

2023-11-15T17:36:19.827Z DEBUG @wdio/utils:initialiseServices: initialise service "vscode" as NPM package
2023-11-15T17:36:20.837Z INFO chromedriver: Initiate Chromedriver Launcher (v8.1.1)
2023-11-15T17:36:20.837Z INFO @wdio/cli:launcher: Run onPrepare hook
christian-bromann commented 8 months ago

Thanks for reporting. This seems to be a duplicate of #88

mikhail-g commented 8 months ago

proposed the solution at: https://github.com/webdriverio-community/wdio-vscode-service/issues/88#issuecomment-1813076813

mikhail-g commented 8 months ago

hey @christian-bromann do you remember why you made this change https://github.com/webdriverio-community/wdio-vscode-service/commit/1562cd19185af40f2269daa0574bb130201ab557? This seems to be a cause of this issue