单元测试面板
- 打开 Visual Studio Code设置当前workspace
/.vscode/setting.json
{
"mochaExplorer.fullTrace": true,
"mochaExplorer.configFile": ".mocharc.json",
}
- 新建mocha配置文件
/.mocharc.json
{
"spec": ["test/**/*.test.js"],
"reporter": "spec",
"timeout": 20000,
"ui": "bdd"
}
普通运行调试
- 打开配置文件/.vscode/launch.json
- 新建项选择 nodejs: mocha tests
{
"args": [
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/test"
],
"internalConsoleOptions": "openOnSessionStart",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},