如何在Sails.js中进行测试时进行调试

时间:2019-07-21 20:10:33

标签: node.js visual-studio-code mocha sails.js

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

我正在从另一个文件中获取错误,是否可以在此处放置断点并在测试时查看它

谢谢您的帮助

2 个答案:

答案 0 :(得分:1)

即使我也遇到了同样的确切问题,尽管我没有找到解决方法是手动开帆并手动完成,但我想您问的原因是因为您想避免最初输入数据的麻烦,有一些解决方法,例如引导数据。

我会做下面的事情,我再说一遍,这只是一种解决方法,如果有人可以给出这个问题的真实答案,那将是很好的。

我将乘风破浪,然后制作一个http文件,用于一次发布所有数据。

然后从错误的来源开始调试。

第一个用于发布数据,其他请求可用于调试






POST http://localhost:1337/api/v1/users HTTP/1.1
content-type: application/json

{
    "emailAddress": "sdfes14@gmail.com",
    "password": "hashedPasswordUser",
    "fullName": "siddhant",
    "location": "vellore",
    "image": "nothhcfyu noini pic",
    "mobile": "9481411113",
    "description": "words cant describe me"
}

###

POST http://localhost:1337/api/v1/users/entrance/login HTTP/1.1
content-type: application/json

{
    "emailAddress": "sdfes14@gmail.com",
    "password": "hashedPasswordUser"
}

###

POST http://localhost:1337/api/v1/qrcode/generator HTTP/1.1
content-type: application/json

{
    "userId": "1141234234",
    "studioId": "54345645634565",
    "bookedServiceId": "76545676545676",
    "serviceName": "gym"
}

答案 1 :(得分:0)

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

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"
    }
  ]
}

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

相关问题