{"id":13758270,"url":"https://github.com/webdriverio-community/wdio-vscode-service","last_synced_at":"2025-04-04T09:06:35.520Z","repository":{"id":37598688,"uuid":"468765741","full_name":"webdriverio-community/wdio-vscode-service","owner":"webdriverio-community","description":"A service to test VSCode extensions from end to end using WebdriverIO","archived":false,"fork":false,"pushed_at":"2025-02-13T07:48:45.000Z","size":2340,"stargazers_count":36,"open_issues_count":38,"forks_count":30,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-28T08:06:35.527Z","etag":null,"topics":["vscode","wdio-plugin","wdio-service","webdriverio"],"latest_commit_sha":null,"homepage":"https://webdriverio-community.github.io/wdio-vscode-service/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webdriverio-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-11T13:42:05.000Z","updated_at":"2025-02-28T21:36:35.000Z","dependencies_parsed_at":"2024-08-03T13:01:17.445Z","dependency_job_id":"69ab5538-ac32-426c-a30a-24507d34b5e7","html_url":"https://github.com/webdriverio-community/wdio-vscode-service","commit_stats":{"total_commits":165,"total_committers":8,"mean_commits":20.625,"dds":0.2606060606060606,"last_synced_commit":"aab1e113633e05ac2b76247d4c27faf06316baba"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdriverio-community%2Fwdio-vscode-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdriverio-community%2Fwdio-vscode-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdriverio-community%2Fwdio-vscode-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdriverio-community%2Fwdio-vscode-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webdriverio-community","download_url":"https://codeload.github.com/webdriverio-community/wdio-vscode-service/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vscode","wdio-plugin","wdio-service","webdriverio"],"created_at":"2024-08-03T13:00:23.863Z","updated_at":"2025-04-04T09:06:35.501Z","avatar_url":"https://github.com/webdriverio-community.png","language":"TypeScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://webdriver.io/\"\u003e\n        \u003cimg alt=\"WebdriverIO loves VSCode\" src=\"https://raw.githubusercontent.com/webdriverio-community/wdio-vscode-service/main/.github/assets/banner.png\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# WDIO VSCode Service [![CI](https://github.com/webdriverio-community/wdio-vscode-service/actions/workflows/ci.yml/badge.svg)](https://github.com/webdriverio-community/wdio-vscode-service/actions/workflows/ci.yml)\n\nTested on:\n\n[![VSCode Version](https://img.shields.io/badge/VSCode%20Version-insiders%20/%20stable%20/%20v1.86.0%20/%20web-brightgreen)](https://github.com/webdriverio-community/wdio-vscode-service/actions/workflows/ci.yml) [![CI Status](https://img.shields.io/badge/Platform-windows%20%2F%20macos%20%2F%20ubuntu-brightgreen)](https://github.com/webdriverio-community/wdio-vscode-service/actions/workflows/ci.yml)\n\n\u003e WebdriverIO service for testing VSCode extensions.\n\nThis WebdriverIO service allows you to seamlessly test your VSCode extensions from end to end in the VSCode Desktop IDE or as a web extension. You only need to provide a path to your extension and the service does the rest by:\n\n- 🏗️ Installing VSCode (either `stable`, `insiders` or a specified version)\n- ⬇️ Downloading Chromedriver specific to a given VSCode version\n- 🚀 Enables you to access the VSCode API from your tests\n- 🖥️ Starting VSCode with custom user settings (including support for VSCode on Ubuntu, MacOS and Windows)\n- 🌐 Or serves VSCode from a server to be accessed by any browser for testing [web extensions](https://code.visualstudio.com/api/extension-guides/web-extensions)\n- 📔 Bootstrapping page objects with locators matching your VSCode version\n\nThis project was highly inspired by the [vscode-extension-tester](https://www.npmjs.com/package/vscode-extension-tester) project which is based on Selenium. This package takes the idea and adapts it to WebdriverIO.\n\nStarting from VSCode v1.86 it is required to use `webdriverio` v8.14 or later to install Chromedriver with no configuration necessary. If you need to test  earlier versions of VSCode, see the [Chromedriver configuration](#chromedriver) section below.\n\n## Installation\n\nTo initiate a new WebdriverIO project, run:\n\n```bash\nnpm create wdio ./\n```\n\nAn installation wizard will guide you through the process. Ensure you select TypeScript as compiler and don't have it generate page objects for you given this project comes with all page objects needed. Then make sure to select `vscode` within the list of services:\n\n![Install Demo](https://raw.githubusercontent.com/webdriverio-community/wdio-vscode-service/main/.github/assets/demo.gif \"Install Demo\")\n\nFor more information on how to install `WebdriverIO`, please check the [project docs](https://webdriver.io/docs/gettingstarted).\n\n## Example Configuration\n\nTo use the service you need to add `vscode` to your list of services, optionally followed by a configuration object. This will make WebdriverIO download given VSCode binaries and appropriate Chromedriver version:\n\n```js\n// wdio.conf.ts\nexport const config = {\n    outputDir: 'trace',\n    // ...\n    capabilities: [{\n        browserName: 'vscode',\n        browserVersion: '1.86.0', // \"insiders\" or \"stable\" for latest VSCode version\n        'wdio:vscodeOptions': {\n            extensionPath: __dirname,\n            userSettings: {\n                \"editor.fontSize\": 14\n            }\n        }\n    }],\n    services: ['vscode'],\n    /**\n     * Optionally define the path WebdriverIO stores all VSCode binaries, e.g.:\n     * services: [['vscode', { cachePath: __dirname }]]\n     */\n    // ...\n};\n```\n\nIf you define `wdio:vscodeOptions` with any other `browserName` but `vscode`, e.g. `chrome`, the service will serve the extension as a web extension. If you test on Chrome no additional driver service is required, e.g.:\n\n```js\n// wdio.conf.ts\nexport const config = {\n    outputDir: 'trace',\n    // ...\n    capabilities: [{\n        browserName: 'chrome',\n        'wdio:vscodeOptions': {\n            extensionPath: __dirname\n        }\n    }],\n    services: ['vscode'],\n    // ...\n};\n```\n\n_Note:_ when testing web extensions you can only choose between `stable` or `insiders` as `browserVersion`.\n\n### TypeScript Setup\n\nIn your `tsconfig.json` make sure to add `wdio-vscode-service` to your list of types:\n\n```json\n{\n    \"compilerOptions\": {\n        \"types\": [\n            \"node\",\n            \"webdriverio/async\",\n            \"@wdio/mocha-framework\",\n            \"expect-webdriverio\",\n            \"wdio-vscode-service\"\n        ],\n        \"target\": \"es2019\",\n        \"moduleResolution\": \"node\",\n        \"esModuleInterop\": true\n    }\n}\n```\n\n## Usage\n\nYou can then use the `getWorkbench` method to access the page objects for the locators matching your desired VSCode version:\n\n```ts\ndescribe('WDIO VSCode Service', () =\u003e {\n    it('should be able to load VSCode', async () =\u003e {\n        const workbench = await browser.getWorkbench()\n        expect(await workbench.getTitleBar().getTitle())\n            .toBe('[Extension Development Host] - README.md - wdio-vscode-service - Visual Studio Code')\n    })\n})\n```\n\n### Accessing VSCode APIs\n\nIf you like to execute certain automation through the [VSCode API](https://code.visualstudio.com/api/references/vscode-api) you can do that by running remote commands via the custom `executeWorkbench` command. This command allows you to remotely execute code from your test inside the VSCode environment and enables you to access the VSCode API. You can pass arbitrary parameters into the function which will then be propagated into the function. The `vscode` object will be always passed in as the first argument following the outer function parameters. Note that you can not access variables outside of the function scope as the callback is executed remotely. Here is an example:\n\n```ts\nconst workbench = await browser.getWorkbench()\nawait browser.executeWorkbench((vscode, param1, param2) =\u003e {\n    vscode.window.showInformationMessage(`I am an ${param1} ${param2}!`)\n}, 'API', 'call')\n\nconst notifs = await workbench.getNotifications()\nconsole.log(await notifs[0].getMessage()) // outputs: \"I am an API call!\"\n```\n\nFor the full page object documentation, check out the [docs](https://webdriverio-community.github.io/wdio-vscode-service/modules.html). You can find various usage examples in this [project's test suite](https://github.com/webdriverio-community/wdio-vscode-service/blob/main/test/specs).\n\n## Configuration\n\nThrough service configuration, you can manage the VSCode version as well as user settings for VSCode:\n\n### Service Options\n\nService options are options needed for the service to set up the test environment.\n\n#### `cachePath`\n\nDefine a cache path to avoid re-downloading VS Code bundles. This is useful for CI/CD to avoid re-downloading VSCode for every test run.\n\nType: `string`\u003cbr /\u003e\nDefault: `process.cwd()`\n\n### VSCode Capabilities (`wdio:vscodeOptions`)\n\nIn order to run tests through VSCode you have to define `vscode` as `browserName`. You can specify the VSCode version by providing a `browserVersion` capability. Custom VSCode options are then defined within the custom `wdio:vscodeOptions` capability. The options are the following:\n\n#### `binary`\n\nPath to a locally installed VSCode installation. If the option is not provided the service will download VSCode based on the given `browserVersion` (or `stable` if not given).\n\nType: `string`\n\n#### `extensionPath`\n\nDefine the directory to the extension you want to test.\n\nType: `string`\n\n#### `storagePath`\n\nDefine a custom location for VS Code to store all its data. This is the root for internal VS Code directories such as (partial list)\n* **user-data-dir**: The directory where all the user settings (global settings), extension logs etc are stored.\n* **extension-install-dir**: The directory where VS Code extensions are installed.\n\nIf not provided, a temporary directory is used.\n\nType: `string`\n\n#### `userSettings`\n\nDefine custom user settings to be applied to VSCode.\n\nType: `Record\u003cstring, number | string | object | boolean\u003e`\u003cbr /\u003e\nDefault: `{}`\n\n#### `workspacePath`\n\nOpens VSCode for a specific workspace. If not provided VSCode starts without a workspace opened.\n\nType: `string`\n\n#### `filePath`\n\nOpens VSCode with a specific file opened.\n\nType: `string`\n\n#### `vscodeArgs`\n\nAdditional start-up arguments as an object, e.g.\n\n```ts\nvscodeArgs: { fooBar: true, 'bar-foo': '/foobar' }\n```\n\nwill be passed in as:\n\n```ts\n--foo-bar --fooBar --bar-foo=/foobar\n```\n\nType: `Record\u003cstring, string | boolean\u003e`\u003cbr /\u003e\nDefault: see [`constants.ts#L5-L14`](https://github.com/webdriverio-community/wdio-vscode-service/blob/196a69be3ac2fb82d9c7e4f19a2a1c8ccbaec1e2/src/constants.ts#L5-L14)\n\n#### `verboseLogging`\n\nIf set to true, the service logs VSCode output from the extension host and console API.\n\nType: `boolean`\u003cbr /\u003e\nDefault: `false`\n\n#### `vscodeProxyOptions`\n\nVSCode API proxy configurations define how WebdriverIO connects to the VSCode workbench to give you access to the VSCode API.\n\nType: `VSCodeProxyOptions`\u003cbr /\u003e\nDefault:\n\n```ts\n{\n    /**\n     * If set to true, the service tries to establish a connection with the\n     * VSCode workbench to enable access to the VSCode API\n     */\n    enable: true,\n    /**\n     * Port of the WebSocket connection used to connect to the workbench.\n     * By default set to an available port in your operating system.\n     */\n    // port?: number\n    /**\n     * Timeout for connecting to WebSocket inside of VSCode\n     */\n    connectionTimeout: 5000,\n    /**\n     * Timeout for command to be executed within VSCode\n     */\n    commandTimeout: 5000\n}\n```\n\n### Chromedriver\n\nStarting from VSCode v1.86 it is required to use `webdriverio` v8.14 or later to install Chromedriver with no configuration necessary. The [simplified browser automation setup](https://webdriver.io/blog/2023/07/31/driver-management) handles everything for you.\n\nTo test earlier versions of VS Code, find the expected version of Chromedriver from the logs, download [Chromedriver](https://chromedriver.chromium.org/downloads), and configure the path. For example:\n\n```\n[0-0] ERROR webdriver: Failed downloading chromedriver v108: Download failed: ...\n```\n\n```ts\n    capabilities: [{\n        browserName: 'vscode',\n        browserVersion: '1.80.0',\n        'wdio:chromedriverOptions': {\n            binary: path.join(cacheDir, 'chromedriver-108.0.5359.71')\n```\n\n## Create Your Own PageObjects\n\nYou can reuse the components used in this service for your own review page objects. For that first create a file that defines all your selectors, e.g.:\n\n```ts\n// e.g. in /test/pageobjects/locators.ts\nexport const componentA = {\n    elem: 'form', // component container element\n    submit: 'button[type=\"submit\"]', // submit button\n    username: 'input.username', // username input\n    password: 'input.password' // password input\n}\n```\n\nNow you can create a page object as follows:\n\n```ts\n// e.g. in /test/pageobjects/loginForm.ts\nimport { PageDecorator, IPageDecorator, BasePage } from 'wdio-vscode-service'\nimport * as locatorMap, { componentA as componentALocators } from './locators'\nexport interface LoginForm extends IPageDecorator\u003ctypeof componentALocators\u003e {}\n@PageDecorator(componentALocators)\nexport class LoginForm extends BasePage\u003ctypeof componentALocators, typeof locatorMap\u003e {\n    /**\n     * @private locator key to identify locator map (see locators.ts)\n     */\n    public locatorKey = 'componentA' as const\n\n    public login (username: string, password: string) {\n        await this.username$.setValue(username)\n        await this.password$.setValue(password)\n        await this.submit$.click()\n    }\n}\n```\n\nNow in your test, you can use your page object as follows:\n\n```ts\nimport { LoginForm } from '../pageobjects/loginForm'\nimport * as locatorMap from '../locators'\n\n// e.g. in /test/specs/example.e2e.ts\ndescribe('my extension', () =\u003e {\n    it('should login', async () =\u003e {\n        const loginForm = new LoginForm(locatorMap)\n        await loginForm.login('admin', 'test123')\n\n        // you can also use page object elements directly via `[selector]$`\n        // or `[selector]$$`, e.g.:\n        await loginForm.submit$.click()\n\n        // or access locators directly\n        console.log(loginForm.locators.username)\n        // outputs: \"input.username\"\n    })\n})\n```\n\n## TypeScript Support\n\nIf you use WebdriverIO with TypeScript make sure to add `wdio-vscode-service` to your `types` in your `tsconfig.json`, e.g.:\n\n```json\n{\n    \"compilerOptions\": {\n        \"moduleResolution\": \"node\",\n        \"types\": [\n            \"webdriverio/async\",\n            \"@wdio/mocha-framework\",\n            \"expect-webdriverio\",\n            // add this service to your types\n            \"wdio-devtools-service\"\n        ],\n        \"target\": \"es2019\"\n    }\n}\n```\n\n## Proxy Support\n\nDuring the initialization of this service, a ChromeDriver and VSCode distribution is downloaded. You can tunnel this requests through a proxy by setting the environment variable `HTTPS_PROXY` or `https_proxy`. E. g.:\n\n```bash\nHTTPS_PROXY=http://127.0.0.1:1080 npm run wdio\n```\n\n## References\n\nThe following VS Code extensions use `wdio-vscode-service`:\n\n- [Marquee](https://marketplace.visualstudio.com/items?itemName=stateful.marquee) (27k downloads)\n- [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) (27.8m downloads)\n- [DVC Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=Iterative.dvc) (11.2k downloads)\n- [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console) (1.2m downloads)\n- [inlang – i18n supercharged](https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension) (3k downloads)\n\n## Contributing\n\nBefore posting a pull request, please run the following:\n\n1. `git clone git@github.com:webdriverio-community/wdio-vscode-service.git`\n1. `cd wdio-vscode-service`\n1. `npm install`\n1. `npm run build`\n1. `npm run test` (or `npm run ci`)\n\n## Learn More\n\nIf you want to learn more about testing VSCode Extensions, check out [Christian Bromann's](https://twitter.com/bromann) talk at [OpenJS World 2022](https://www.youtube.com/watch?v=PhGNTioBUiU):\n\n[![Testing VSCode Extensions at OpenJS World 2022](https://img.youtube.com/vi/PhGNTioBUiU/sddefault.jpg)](https://www.youtube.com/watch?v=PhGNTioBUiU)\n\n---\n\nFor more information on WebdriverIO check out the project [homepage](https://webdriver.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebdriverio-community%2Fwdio-vscode-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebdriverio-community%2Fwdio-vscode-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebdriverio-community%2Fwdio-vscode-service/lists"}