gpt4 book ai didi

visual-studio-code - 用于 Jest VSCode 扩展测试运行器

转载 作者:行者123 更新时间:2023-12-01 05:55:47 25 4
gpt4 key购买 nike

使用 official generator 时要启动 VSCode 扩展,它会自动生成 extension.test.tsindex.ts文件。 index.ts 只包含用于扩展测试的测试运行器的设置,它是基于 Mocha 的。 Mocha 测试运行器本身可以在这里看到:https://github.com/Microsoft/vscode-extension-vscode/blob/master/lib/testrunner.js .

我一直在四处寻找任何基于 Jest 的官方 Jest。有人知道吗?

最佳答案

没有官方的,你必须自己创建。

Igor Soloydenko 去年(2019 年)写了一份关于如何做到这一点的指南:

https://medium.com/@soloydenko/end-to-end-testing-vs-code-extensions-via-jest-828e5edfeb75

伪代码:

const jestTestRunnerForVSCodeE2E: ITestRunner = {
run(testsRoot: string, clb: (error: Error, failures?: number) => void): void {
try {
const result = runJestTests(configuration);
if (result.executionError) {
clb(result.executionError);
} else {
clb(undefined, result.numberOfFailedTests);
}
} catch (e) {
clb(e);
}
}
};

module.exports = jestTestRunnerForVSCodeE2E;

当然还有@user1795832 提供的链接: https://github.com/rozzzly/vscode-prompt-debug/tree/master/test

该链接中的代码最后更新于 2018 年 5 月,因此不确定它是否仍然有效。

关于visual-studio-code - 用于 Jest VSCode 扩展测试运行器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49615315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com