当不在默认的“/test”文件夹中时,将 Mocha 测试资源管理器与 VScode 一起使用

Jef*_*Eon 5 mocha.js typescript visual-studio-code

我目前正在开发一个项目,其中存储测试文件/code_tests而不是默认的/test. 我试图避免重命名文件夹,但我似乎无法更改 Mocha 测试资源管理器的默认位置。

该项目在 vscode 上使用 Typescript。

文档提供了这行代码。"mochaExplorer.files": "test/**/*.ts"我认为需要更改为,"mochaExplorer.files": "code_tests/**/*.ts"但我似乎无法找到存储此命令的位置以使其按预期工作。

Jef*_*Eon 15

将这些添加到 vscodesettings.json

"mochaExplorer.require": "ts-node/register",
"mochaExplorer.files": "code_tests/**/*.ts",
Run Code Online (Sandbox Code Playgroud)


小智 11

.vscode如果您的项目结构中没有文件夹,请创建一个。并.vscode/settings.json添加以下内容

"mochaExplorer.require": "ts-node/register",
"mochaExplorer.files": "tests/**/*.ts",
Run Code Online (Sandbox Code Playgroud)