I was trying to debug a Mocha script and I’m running into two issues:
- The first issue is that if I set the break point inside the “it” statement, it’s not stopping in the IDE and instead puts a message in the editor that says, “Debugger listening on port 5858”. If I then add a watch expression the Debugger tab will have “Debug Session Ended”. Any watch expressions that existed beforehand have “ReferenceError: somevar is not defined”
- The second issue is that if I put the break point at the closure of the “it” statement, then it will pause correctly and the IDE updates, but my watch expressions still have “ReferenceError: somevar is not defined”
What doesn’t add up is my control was
var debuggertest = "testing123". In my head, that should show up in at least one of the two cases above.
I also tried setting the Runner to Mocha and set the Command to “test/sometest.js”, and it would pause correctly in the IDE at the closure of the “it” block, but if in the “it” block then just runs without stopping and finishes with “Process exited with code: 0”.
Am I doing something wrong, or is this because it’s still experimental? I was hoping to get at the variables in the “it” blocks without console.logging them.
UPDATE: It’s actually in the “request” (supertest) block where it’s not pausing. I added some code after it, but in the “it” block and it will pause correctly and show the variable I set there. I may be using supertest wrong.
FIGURED IT OUT: The request was an asynchronous supertest request. I had forgotten to pass in “done”, so I guess the IDE didn’t know what to do with it. Now that the async block is correct, the IDE is breaking inside at “done()” and I can see the variable contents without issue.