The vscode API documentation includes a page on how to test extensions. This works well when you have a single extension with no dependencies. However, in our case, we extensionDependencies
since our extension depends on hbenl.vscode-test-explorer
.
On our CI server, we have a problem that we cannot run the tests until this dependency is installed, but there is no API exposed by vscode's test API to install extensions.
We could download our own copy of vscode and use the --install-extension
command to install this dependency, but that complicates things since now we are managing the download that the API used to manage.
There are two reasonable possibilities that I would like to explore:
extensionDependencies
when activating my extension?vscode-test
run?Somehow, I missed this in the documentation. Custom setup with vscode-test
.
The code is available at the link, so I won't copy all of it. Here's the most relevant part:
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
// Use cp.spawn / cp.exec for custom setup
cp.spawnSync(cliPath, ['--install-extension', '<EXTENSION-ID-OR-PATH-TO-VSIX>'], {
encoding: 'utf-8',
stdio: 'inherit'
});