使用正确的调试配置文件,我可以让 VSCode 通过 Mocha 运行当前关注的文件。但是,令我沮丧的是,如果我正在处理实际代码而不是规范文件,然后按F5
,它会尝试通过 Mocha 将实际代码作为规范文件运行。
所以,我的问题是;给定这样的文件结构:
Folder
File.js
File.spec.js
和这样的调试配置(.vscode/launch.json
):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Unit Tests: Current File",
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
"cwd": "${workspaceRoot}",
"args": [
"-u", "tdd",
"--timeout=999999",
"--colors",
"--opts", "${workspaceRoot}/mocha.opts",
"${file}" // I want to make this dynamic
],
}
]
}
是否可以让 VSCode 调试规范文件,无论选择规范文件(File.spec.js
)还是它的主题(File.js
)?