如何在 sailsjs 中测试时进行调试

How to debug while testing in sailsjs

我正在尝试调试 sailsjs 中的 500 内部服务器错误。我已经用 mocha 编写了测试,但从那里得到了错误。当我使用 npm 运行 test 开始测试时,我不确定如何 运行 调试器。

我从另一个文件中得到错误,是否可以在那里设置断点并在测试时查看它

感谢您的帮助

所以,这就是我想出的解决方案。

Using VScode,

configure the launch.json to be

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Mocha All",
      "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
      "args": [
        "--timeout",
        "999999",
        "--colors",
        "${workspaceFolder}/test/**/*.spec.js"
      ],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Mocha Current File",
      "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
      "args": ["--timeout", "999999", "--colors", "${file}"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
  ]
}

根据项目中测试文件的标记方式进行更改