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
33 stars 28 forks source link

Missing `Contents/Resources/app/out/vs/base/index.js` #123

Open haberdashPI opened 3 months ago

haberdashPI commented 3 months ago

When calling the following example code from the documentation:

const workbench = await browser.getWorkbench()
await browser.executeWorkbench((vscode, param1, param2) => {
    vscode.window.showInformationMessage(`I am an ${param1} ${param2}!`)
}, 'API', 'call')

const notifs = await workbench.getNotifications()
console.log(await notifs[0].getMessage()) 

I get an error about [prefix]Contents/Resources/app/out/vs/base/index.js file missing,

[0-0] 2024-06-16T20:14:58.885Z INFO chromedriver: [FAKE VSCode Binary] STDERR: TypeError: Failed to fetch dynamically imported module: vscode-file://vscode-app/Users/davidlittle/Documents/tools/vscode-master-key/.wdio-vscode-service/vscode-darwin-arm64-1.86.2/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/base/index.js

Inspecting this folder, I see no such file. I tried downloading versions 1.86 - 1.90 of vscode and encountered the same error for each.

Is this an expected error? Is this some issue with my setup?

christian-bromann commented 3 months ago

@haberdashPI this is definitely not expected, not sure how this is actually related to this package but it certainly may. Any investigations and help to resolve this issue would be appreciated.

haberdashPI commented 3 months ago

Thank you @christian-bromann; I'm happy to try to do some digging myself. About the index.js file that executeWorkbench is looking for: I had assumed this was something that was straightforwardly being accessed in this repository to access the VSCode API, but from what you're saying that doesn't sound right anymore.

Is the place to get started to review the code of executeWorkbench? Anything else in this repository (or elsewhere) I should be looking to better understand what executeWorkbench is doing and why it would be looking for a file that doesn't exist within the VSCode app?

haberdashPI commented 3 months ago

Update: this seems to be independent of calling executeWorkbench: I get a similar error when calling executeCommand, so I am assuming this is some issue with my setup. I will try to make a MWE starting from scratch with a new project rather than trying to get this working on my existing VSCode extension I am trying to develop tests for.

async function specForBindings(text: string) {
    let workbench = await browser.getWorkbench();
    let config = path.join(tempdir, 'config.toml');
    fs.writeFileSync(config, text);
    console.log("[USER]: executing keybinding activation command");
    let input = await workbench.executeCommand('Master Key: Activate Keybindings');
    console.log("[USER]: requesting file selector");
    await input.setText('File...');
    await input.confirm();
    console.log("[USER]: specifying config file as input");
    await input.setText(config);
    await input.confirm();
}
[0-0] [USER]: executing keybinding activation command
[0-0] 2024-06-17T21:19:53.995Z INFO webdriver: COMMAND findElement("css selector", "div[id="workbench.parts.editor"]")
[0-0] 2024-06-17T21:19:53.995Z INFO webdriver: [POST] http://0.0.0.0:55240/session/eb3f09e4f02cc73e881104bbb69a37f8/element
[0-0] 2024-06-17T21:19:53.995Z INFO webdriver: DATA { using: 'css selector', value: 'div[id="workbench.parts.editor"]' }
[0-0] 2024-06-17T21:19:54.008Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': '8FE56A23B0C57B6FA486257C2C7ED20C_element_68'
[0-0] }
[0-0] 2024-06-17T21:19:54.009Z INFO webdriver: COMMAND executeScript(<fn>, <object>)
[0-0] 2024-06-17T21:19:54.010Z INFO webdriver: [POST] http://0.0.0.0:55240/session/eb3f09e4f02cc73e881104bbb69a37f8/execute/sync
[0-0] 2024-06-17T21:19:54.010Z INFO webdriver: DATA {
[0-0]   script: 'isElementDisplayed(...) [8489 bytes]',
[0-0]   args: [
[0-0]     {
[0-0]       'element-6066-11e4-a52e-4f735466cecf': '8FE56A23B0C57B6FA486257C2C7ED20C_element_68',
[0-0]       ELEMENT: '8FE56A23B0C57B6FA486257C2C7ED20C_element_68'
[0-0]     }
[0-0]   ]
[0-0] }
[0-0] 2024-06-17T21:19:54.019Z INFO webdriver: RESULT true
[0-0] 2024-06-17T21:19:54.019Z INFO webdriver: COMMAND findElement("css selector", "div[id="workbench.parts.editor"]")
[0-0] 2024-06-17T21:19:54.019Z INFO webdriver: [POST] http://0.0.0.0:55240/session/eb3f09e4f02cc73e881104bbb69a37f8/element
[0-0] 2024-06-17T21:19:54.019Z INFO webdriver: DATA { using: 'css selector', value: 'div[id="workbench.parts.editor"]' }
[0-0] 2024-06-17T21:19:54.035Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': '8FE56A23B0C57B6FA486257C2C7ED20C_element_68'
[0-0] }
[0-0] 2024-06-17T21:19:54.036Z INFO webdriver: COMMAND findElementsFromElement("8FE56A23B0C57B6FA486257C2C7ED20C_element_68", "xpath", ".//div[starts-with(@id, 'webview-editor')]")
[0-0] 2024-06-17T21:19:54.037Z INFO webdriver: [POST] http://0.0.0.0:55240/session/eb3f09e4f02cc73e881104bbb69a37f8/element/8FE56A23B0C57B6FA486257C2C7ED20C_element_68/elements
[0-0] 2024-06-17T21:19:54.037Z INFO webdriver: DATA { using: 'xpath', value: ".//div[starts-with(@id, 'webview-editor')]" }
[0-0] 2024-06-17T21:19:54.039Z INFO chromedriver: [FAKE VSCode Binary] STDOUT: No keybindings found at: vscode-userdata:/var/folders/mn/0t3k_r3d1c5_2256500t9qjc0000gq/T/tmp-18014-mmAet5khrROR/settings/User/globalStorage/haberdashpi.master-key/config.json
[0-0] 2024-06-17T21:19:54.039Z INFO chromedriver: 
[0-0] 2024-06-17T21:19:54.057Z INFO webdriver: RESULT []
[0-0] 2024-06-17T21:19:54.059Z INFO webdriver: COMMAND performActions(<object>)
[0-0] 2024-06-17T21:19:54.060Z INFO webdriver: [POST] http://0.0.0.0:55240/session/eb3f09e4f02cc73e881104bbb69a37f8/actions
[0-0] 2024-06-17T21:19:54.060Z INFO webdriver: DATA {
[0-0]   actions: [ { id: 'action1', type: 'key', parameters: {}, actions: [Array] } ]
[0-0] }
[0-0] 2024-06-17T21:19:54.067Z INFO chromedriver: [FAKE VSCode Binary] STDERR: TypeError: Failed to fetch dynamically imported module: vscode-file://vscode-app/Users/davidlittle/Documents/tools/master-key/.wdio-vscode-service/vscode-darwin-arm64-1.86.2/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/base/index.js
[0-0] 2024-06-17T21:19:54.067Z INFO chromedriver: [18044:0617/171954.067182:INFO:CONSOLE(2750)] "TypeError: Failed to fetch dynamically imported module: vscode-file://vscode-app/Users/davidlittle/Documents/tools/master-key/.wdio-vscode-service/vscode-darwin-arm64-1.86.2/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/base/index.js", source: vscode-file://vscode-app/Users/davidlittle/Documents/tools/master-key/.wdio-vscode-service/vscode-darwin-arm64-1.86.2/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js (2750)
[0-0] 2024-06-17T21:19:54.067Z INFO chromedriver: 
[0-0] 2024-06-17T21:19:54.076Z INFO chromedriver: [FAKE VSCode Binary] STDOUT: [main 2024-06-17T21:19:54.076Z] Extension host with pid 18070 exited with code: 0, signal: unknown.
[0-0] 2024-06-17T21:19:54.076Z INFO chromedriver: 
[0-0] 2024-06-17T21:19:54.102Z WARN chromedriver: [1718659194.102][WARNING]: Processing messages while being disconnected
[0-0] RequestError in "Simple Keybinding File.can be parsed"
RequestError: socket hang up
haberdashPI commented 3 months ago

After a little bit more investigation, it appears that the main issue here is that when creating a web extension, one has to set browser to an actual browser in in wdio.conf.ts. When I switched from using 'vscode' to 'chrome' a basic test now works. I will try to extract this into a small MWE repo with a hello world program as time allows.