NodeJS 调试器在节点点击时启动,而不是在测试文件上启动

slmsl1lt  于 11个月前  发布在  Node.js
关注(0)|答案(1)|浏览(117)

我尝试在docker中调试一个与node-tap一起运行的测试文件。我添加了running命令,配置调试器连接到docker。一切正常,测试运行,调试器连接,但它调试的是node-tap模块,而不是测试文件。
我有以下命令:

"dev:test": "NODE_ENV=test tap --debug --node-arg=--loader=ts-node/esm --node-arg=--no-warnings --node-arg=--experimental-specifier-resolution=node --node-arg=--inspect-brk=0.0.0.0:3034 tests/e2e/component.test.ts --timeout=1200 --jobs=1"

字符串
这是launch.json

{
"version": "0.2.0",
"configurations": [
  {
    "name": "Attach to Docker",
    "type": "node",
    "request": "attach",
    "port": 3034,
    "address": "0.0.0.0",
    "localRoot": "${workspaceFolder}",
    "remoteRoot": "/app",
    "restart": true,
    "outFiles": ["${workspaceFolder}/build/**/*.js"],
    "skipFiles": ["<node_internals>/**/*.js", "${workspaceFolder}/node_modules/**/*.js"]
  }
]


}
当我运行yarn dev:test时,调试器连接,但我被发送到:

另外,当我在测试文件中添加断点时,它说:some of the brakpoints could not be set
我发现将属性program添加到指向我要运行的文件的launch.json可以解决这个问题,但它说属性is not allowed
我还尝试指向localRootremoteRoot中的不同位置,但它也不起作用。
会是什么呢?

gwo2fgha

gwo2fgha1#

找到问题了。
似乎是launch.json中的outFiles导致了这个问题。在删除它并让它采用默认值后,它工作了。(据我所知,这是针对yarn的)。
它仍然在tap模块中启动调试,但如果我按下f5(继续),它将在我设置的下一个断点处停止。

相关问题