【问题标题】:How to resolve an error which i am getting when installing vscode for testing my extension?如何解决我在安装 vscode 以测试我的扩展程序时遇到的错误?
【发布时间】:2021-03-23 12:28:57
【问题描述】:

我现在从 github 模板中做了一个 vscode 扩展来测试我必须按照指南运行这个命令

node ./node_modules/vscode/bin/test

安装 vscode 来测试我的分机。但安装后我得到的输出为

Downloading VS Code 1.54.3 into .vscode-test/vscode-1.54.3.
Downloading VS Code from: https://update.code.visualstudio.com/1.54.3/win32-archive/stable
Downloaded VS Code 1.54.3
Test error: Error: spawn E:\NewProj\glitter-ext\.vscode-test\vscode-1.54.3\Code.exe ENOENT
Exit code:   -4058
Done

Failed

在这我不知道我该怎么办? 我的分机代码是

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

    console.log('Congratulations, your extension "hello-world-vscode-extension" is now active!');

    let disposable = vscode.commands.registerCommand('extension.sayHello', () => {
        vscode.window.showInformationMessage('Hello World!');
    });

    context.subscriptions.push(disposable);
}

编辑:

我设法将 vscode 安装到 ./vscode-test 文件夹。现在我写了一个类似这样的测试文件

const { runTests } = require('vscode-test');
const path = require('path');

async function test() {
    try{
        await runTests({
            extensionPath: path.join(__dirname, "../dist/"),
            testRunnerPath: path.join(__dirname, "../.vscode-test/"),
            extensionDevelopmentPath: path.join(__dirname, "../dist/")
        })
    }catch(e){
        console.error(e);
    }
}

test();

这个文件被命名为test/index.js 现在当我运行这个文件时,一切都很好,vscode 打开进行测试,并以同样的速度关闭并显示控制台失败:

Exit code:   1
Done

Failed

【问题讨论】:

  • vsc 安装在哪个目录:./vscode-test../.vscode-test/.

标签: typescript visual-studio-code vscode-extensions


【解决方案1】:

通过additional Launch configwrite the index.(ts/js) file and your test files 使用当前VSC。

从运行/调试栏中选择此配置并按 F5。

现在无需下载 VSC。

【讨论】:

  • 好吧,我需要更新它,因为现在我手动将 vsc 下载到了.vscode-test/ 文件夹,但现在在我测试代码时出现了一个新错误。一切都很好,但是随着可视化代码打开以进行测试,它同时被关闭。没有错误,但控制台显示Failed
猜你喜欢
  • 2020-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-05
  • 2016-12-24
相关资源
最近更新 更多