Skip to content
Jan Richter edited this page Jan 22, 2020 · 22 revisions

VSCode Extension Tester

VSCode Extension Tester is a package designed to help you run UI tests for your VS Code extensions using selenium-webdriver. Simply install it into your extension devDependencies to get started:

npm install --save-dev vscode-extension-tester

As such there are two major parts to the project:

Test Setup

The first part automates all the steps necessary to launch UI tests of your VSCode extension:

  • Download a test instance of VS Code
  • Download the appropriate version of ChromeDriver
  • Package and install your extension into the VS Code instance
  • Launch the VS Code instance using webdriver
  • Run your tests

Find more about the test setup: Test-Setup

See how to change the Mocha test runner configuration: Mocha-Configuration

Once the setup is complete, check out the sample test file: Writing-Simple-Tests.


Page Object APIs

Once your tests are set up and running, you may use the convenient page object API to handle parts of VSCode without sifting through its DOM. Though, if using pure webdriver is preferred, all the webdriver APIs are exported as well.

Find documentation about the Page Object APIs: Page-Object-APIs.


Opening Files and Folders

Opening files and folders is basic functionality of VS Code. Sadly, it can only be done by stepping through native dialogs, which can't be handled by webdriver. Hence the OpenDialog class that handles such dialogs via key presses. This approach is not guaranteed to work on all platforms though.

The second possible approach is to use the small extension the framework installs into vscode for each test run. It contributes the following commands:

  • Extest: Open File - open given path as text file in the editor
  • Extest: Open Folder - open a given folder in workspace, closing any other currently open folders
  • Extest: Add Folder to Workspace - add a given folder to the current workspace

Use these commands if you need a file or a folder in your workspace and don't really care how it got there. Simply execute the given command (e.g. by calling Workbench#executeCommand method), fill in the desired absolute path into the input box that appears and confirm.

Clone this wiki locally