【问题标题】:Debugging mocha-cakes-2 with Visual Studio Code使用 Visual Studio Code 调试 mocha-cakes-2
【发布时间】:2018-10-06 13:34:55
【问题描述】:

我有一个使用 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?

【问题讨论】:

    标签: node.js visual-studio-code mocha.js vscode-settings vscode-debugger


    【解决方案1】:

    我想这应该通过传递 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"
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 2015-07-13
      • 1970-01-01
      • 1970-01-01
      • 2022-08-11
      • 2016-07-29
      • 1970-01-01
      相关资源
      最近更新 更多