Skip to content

Commit

Permalink
Fix problems with cachePath service option
Browse files Browse the repository at this point in the history
Using the `vscode` service with the `cachePath` option:
```js
services: [["vscode", {cachePath: "/tmp/wdio-vscode-service"}]],
```

On the `6.0.0` version this results failure to run tests with this error:
```
ERROR @wdio/runner: Error: Invalid or unsupported WebDriver capabilities found ("cachePath"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to your vendor support team if you have further questions.
```

Seems like `cachePath` is not a capability based on any of the wdio types.
Looking at the code, it seems like before assigning `options` to the
capabilities made sense because `options` field actually contained different
things in the wdio-chromedriver-service - https://github.com/webdriverio-community/wdio-chromedriver-service/blob/104e63525faa156866aa521397ae56ffc6059a8f/src/launcher.ts#L47

Right now the options are only relevant for the `vscode` service, so I've
removed all logic that merges them into capabilities.
  • Loading branch information
ilia-db committed Feb 16, 2024
1 parent 3495db2 commit d5ef5a4
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import type { Capabilities } from '@wdio/types'
import { HttpsProxyAgent } from 'hpagent'

import startServer from './server/index.js'
import {
fileExist, directoryExists, isMultiremote, isChrome
} from './utils.js'
import { fileExist, directoryExists } from './utils.js'
import {
DEFAULT_CHANNEL, VSCODE_RELEASES, VSCODE_MANIFEST_URL, DEFAULT_CACHE_PATH,
VSCODE_CAPABILITY_KEY, VSCODE_WEB_STANDALONE, DEFAULT_VSCODE_WEB_HOSTNAME
Expand Down Expand Up @@ -64,10 +62,7 @@ export default class VSCodeServiceLauncher {
private _cachePath: string
private _vscodeServerPort?: number

constructor (
private _options: ServiceOptions,
private _capabilities: WebdriverIO.Capabilities
) {
constructor (private _options: ServiceOptions) {
this._cachePath = this._options.cachePath || DEFAULT_CACHE_PATH
}

Expand Down Expand Up @@ -105,7 +100,6 @@ export default class VSCodeServiceLauncher {
* setup VSCode Web
*/
await this._setupVSCodeWeb(version, cap)
this._mapBrowserCapabilities(this._options)
}
}

Expand Down Expand Up @@ -168,8 +162,6 @@ export default class VSCodeServiceLauncher {
log.info(
`Skipping download, bundle for VSCode v${vscodeVersion} already exists`
)

Object.assign(cap, this._options)
cap.browserVersion = chromedriverVersion
cap[VSCODE_CAPABILITY_KEY].binary ||= await this._downloadVSCode(vscodeVersion)
return
Expand All @@ -179,7 +171,6 @@ export default class VSCodeServiceLauncher {
const vscodeVersion = await this._fetchVSCodeVersion(version)
const chromedriverVersion = await this._fetchChromedriverVersion(vscodeVersion)

Object.assign(cap, this._options)
cap.browserVersion = chromedriverVersion
cap[VSCODE_CAPABILITY_KEY].binary ||= await this._downloadVSCode(vscodeVersion)
await this._updateVersionsTxt(version, vscodeVersion, chromedriverVersion, versionsFileExist)
Expand Down Expand Up @@ -315,16 +306,4 @@ export default class VSCodeServiceLauncher {
'utf-8'
)
}

private _mapBrowserCapabilities (options: ServiceOptions) {
if (isMultiremote(this._capabilities)) {
throw new SevereServiceError('This service doesn\'t support multiremote yet')
}

for (const cap of this._capabilities as any as WebdriverIO.Capabilities[]) {
if (isChrome(cap)) {
Object.assign(cap, options)
}
}
}
}

0 comments on commit d5ef5a4

Please sign in to comment.