node inspector with mocha not working with 'debugger' command

岁酱吖の 提交于 2019-12-01 10:40:44
Thomas

Try placing a breakpoint at the bottom of the mocha library per this issue. For some reason that allows debugger statements in your modules to pause the node debugger.

However it doesn't seem to stop at debugger statements in the spec itself. I have a SO question highlighting that problem.

I was on the latest node version, using the node-debug command (to launch node-inspector and having the same issues you were. Here's what I'm rolling with currently:

Using the following versions:

  • node: 0.11.13 (I downgraded from latest) <-- I specifically had to use this one
  • mocha: 2.2.1 <-- might work with any
  • node-inspector: 0.9.2 <-- might work with any

Start your tests using the following command:

  • node-debug _mocha test/unit-tests.js

Navigate to your test file and start putting in breakpoints, then hit run. I usually put one up by the 'requires' of my test file, and several within my 'it' functions.

Hope that helps, and that one day this kind of thing will just work :P

Got the idea to downgrade node from here: https://www.bountysource.com/issues/7978672-script-is-resumed-as-soon-as-node-inspector-is-loaded

And the command from here: https://github.com/node-inspector/node-inspector#how-do-i-debug-mocha-unit-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!