首页 > 解决方案 > How do I run integration tests for a vscode extension that depends on other extensions

问题描述

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:

  1. How can I disable the extensionDependencies when activating my extension?
  2. How can I download the dependency as part of the vscode-test run?

标签: visual-studio-codeintegration-testingvscode-extensions

解决方案


不知何故,我在文档中错过了这一点。自定义设置vscode-test

代码在链接中可用,所以我不会全部复制。这是最相关的部分:

    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'
    });

推荐阅读