使用 Visual Studio 代码调试 mocha-cakes-2
Debugging mocha-cakes-2 with Visual Studio Code
我用 mocha.js 测试了一个 node.js 项目。我使用 mocha-cakes-2 以黄瓜风格编写我的测试。
这是我的package.json
"devDependencies": {
"chai": "^4.1.2",
"chai-spies": "^1.0.0",
"mocha": "^5.2.0",
"mocha-cakes-2": "^3.3.0",
"should": "^13.2.3",
"should-sinon": "0.0.6",
"sinon": "^6.3.4"},"scripts": {"test": "mocha ./scenarios/**/*.test.js --ui mocha-cakes-2"}
这是我在 VS Code 中的 launch.json
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/tests/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
"'${workspaceFolder}/tests/scenarios/**/*.test.js'"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
当我 运行 测试时,一切正常。但是,当我使用 VS Code 调试测试时,出现以下错误。 ReferenceError:未定义功能
我如何配置 VS Code 调试选项以将 mocha-cakes-2 设置为 mocha 的 UI?
我想这应该可以通过传递 ui
参数来实现
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/tests/node_modules/mocha/bin/_mocha",
"args": [
"--ui", // add it here
"mocha-cakes-2", // add it here
"--timeout",
"999999",
"--colors",
"'${workspaceFolder}/tests/scenarios/**/*.test.js'"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
我用 mocha.js 测试了一个 node.js 项目。我使用 mocha-cakes-2 以黄瓜风格编写我的测试。
这是我的package.json
"devDependencies": {
"chai": "^4.1.2",
"chai-spies": "^1.0.0",
"mocha": "^5.2.0",
"mocha-cakes-2": "^3.3.0",
"should": "^13.2.3",
"should-sinon": "0.0.6",
"sinon": "^6.3.4"},"scripts": {"test": "mocha ./scenarios/**/*.test.js --ui mocha-cakes-2"}
这是我在 VS Code 中的 launch.json
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/tests/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
"'${workspaceFolder}/tests/scenarios/**/*.test.js'"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
当我 运行 测试时,一切正常。但是,当我使用 VS Code 调试测试时,出现以下错误。 ReferenceError:未定义功能
我如何配置 VS Code 调试选项以将 mocha-cakes-2 设置为 mocha 的 UI?
我想这应该可以通过传递 ui
参数来实现
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/tests/node_modules/mocha/bin/_mocha",
"args": [
"--ui", // add it here
"mocha-cakes-2", // add it here
"--timeout",
"999999",
"--colors",
"'${workspaceFolder}/tests/scenarios/**/*.test.js'"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}