[英]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 . vscode API 文档包括一个关于如何测试扩展的页面。 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
.然而,在我们的例子中,我们是
extensionDependencies
因为我们的扩展依赖于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.在我们的 CI 服务器上,我们有一个问题,在安装此依赖项之前我们无法运行测试,但是 vscode 的测试 API 没有公开用于安装扩展的 API。
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.我们可以下载我们自己的 vscode 副本并使用
--install-extension
命令来安装此依赖项,但这使事情变得复杂,因为现在我们正在管理 API 用于管理的下载。
There are two reasonable possibilities that I would like to explore:我想探讨两种合理的可能性:
extensionDependencies
when activating my extension?extensionDependencies
时禁用 extensionDependencies?vscode-test
run?vscode-test
运行的一部分,如何下载依赖项?Somehow, I missed this in the documentation.不知何故,我在文档中错过了这一点。 Custom setup with
vscode-test
. 使用
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'
});
Some additional information when trying to apply the solution of Andrew.尝试应用 Andrew 的解决方案时的一些附加信息。
test-electro
to your projecttest-electro
添加到您的项目中In package.json
在
package.json
under "devDependencies":
在
"devDependencies":
add "@vscode/test-electron": "^1.6.2",
( choose an appropriate version, that suits you)添加
"@vscode/test-electron": "^1.6.2",
(选择合适的版本,适合你)
Open the extension information page (like when you install an extension).打开扩展信息页面(就像安装扩展时一样)。 You can copy the extension ID when you click on the cogwheel (see below)
您可以在单击齿轮时复制扩展 ID (见下文)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.