VSCode-调试/测试-TextEditor

时间:2019-10-31 15:42:59

标签: typescript debugging testing visual-studio-code

我实现了vscode扩展,现在我想对其进行测试。我的扩展包含3个功能,我可以使用vscode-test的runTest和mocha以及启动配置来测试其中2个:

{
    "name": "Extension Test",
    "type": "extensionHost",
    "request": "launch",
    "runtimeExecutable": "${execPath}",
    "args": [
        "--extensionDevelopmentPath=${workspaceFolder}",
        "--extensionTestsPath=${workspaceFolder}/out/extension/tests/suite/index"
    ],
    "outFiles": [
        "${workspaceFolder}/out/extension/tests/**/*.js"
    ]
}

但是我现在陷入困境,因为第三个函数需要一个vscode.TextEditor,而且我找不到创建或获取一个的方法。 启动此命令不会为测试文件提供任何TextEditor,我尝试使用以下方法获得一个:

let editor1 = vscode.window.visibleTextEditors; // --> length = 0
let editor2 = vscode.window.activeTextEditor; // --> undefined

有没有办法对此进行测试?

0 个答案:

没有答案