-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node inspector #247
Comments
hmm i forget what the interface to node-inspector is, might have to try it out |
you do either : node --debug your/node/program.js or node --debug-brk your/node/program.js On Wed, Feb 1, 2012 at 4:24 PM, TJ Holowaychuk
|
This would be great. Tried debugging my tests with node-inspector and just couldn't seem to get it working. Could get mocha inside web inspector with |
@weepy our |
Node inspector starts up a server which hooks into node's built-in debugger server, allowing you to debug node.js programs with webkit's developer tools (so say, inside google chrome). ... or at least that's how I think it works (could be wrong). |
right right, so --debug just fires up v8's debugging protocol? hmMmmM wonder what to call it to get around the ambiguity issue |
maybe |
agree node-inspector is using --debug and --debug-brk so it would be good to proxy those through. On Fri, Feb 3, 2012 at 10:47 AM, TJ Holowaychuk
|
Just ran over the same issue, needed to fire up node-inspector for a mocha test. --debug vs debug distinction would be cool |
marked as high priority I'll make sure it gets in the next release |
It is working well for me, following the path suggested by @visionmedia Note: This does change the commandline operation of mocha by changing the --debug option's meaning and instead, mapping the previous meaning to debug (no dashes)
that should fix it, I dont use node-inspector if anyone could confirm that would be great! |
|
they work like node's |
If you look at the two lines from processlist above, you'll see that I've run |
hmm odd that's not the case for me |
This working for me. Important: node-inspector doesn't play well with just plain old |
Not sure if related but I just saw a fix for debugbrk in node 6.11
|
OK, I'm not sure what's going on but I'm unable to replicate this on other versions of node or on other computers on the same version of node, so it seems to be my local configuration issue… On all other machines / versions it works as expected. |
i tried using mocha --debug-brk test.js and i could connect via node-inspector but my test script files did not show up in chromes debugger. anyone else have this issue? p.s. i'm on windows |
I'm hitting the same issue as blackjable: I can connect via node-inspector, but no test script files show up in Chrome's debugger. |
I think from technical perspective everything is fine within mocha. also node-inspector is working fine. anyhow the problem is, that node-inspector starts to debug the complete mocha source code. A simple solution would be, that mocha sets a auto-breakpoint at the first test case. |
I am having the same trouble, it's very difficult to get a breakpoint set inside a test. I've been trying to wade through the mocha source to try and get into a function that will let me set a breakpoint on my test, but I still haven't had any luck. I've tried setting a "debugger;" in my source, but it still does not get caught in time. +1 for Chris Rock's suggestion. |
What I ended up having to do:
|
Thank you JudahGabriel for the nice summary and suggestion. I am not able to see my test files after following your suggestion. Nevertheless, I am able to see all the mocha files after following your instructions, and setting a breakpoint in mocha/lib/runnable.js in the first line of the method Runnable.prototype.run (line 154 in mocha 1.4.2). This seems to stop execution after all the test files are loaded, and before the tests are run. I was able to deduce this by putting a breakpoint in node.js' util.inspect which shows in the file navigator when the debug session first starts, placing a console.log(util.inspect...) statement in my test, and consulting the CallStack. I am using Thank you VisionMedia and Danny Coates for Mocha and node-inspector respectively |
Is there any update on this? Stepping through the mocha source line by line until all of my project source files are loaded is terribly painful. I could always not run mocha command-line, instead |
We have released a new version of Node Inspector (0.3) which allows you to set breakpoints in files that are not loaded by node yet. This feature makes debugging of mocha unit-tests much easier:
See our blog post for more details about the new Node Inspector version. |
I have the following trick I use. I create a file in my /*global debugger,v8debug,before,after */
/*jslint debug:true, node:true */
// call the debugger in case we are in debug mode
before(function (done) {
if (typeof(v8debug) !== undefined) {
debugger;
}
done();
}); Since all my other tests are in a With Chrome, works beautifully. |
Thanks @JudahGabriel . Your steps work |
@bajtos Im trying to follow your stepwise procedure for setting breakpoints on the mocha unit tests, but I get stucked in step 3, "Look at source files of your unit-tests and set breakpoints inside them.", what do you mean by "look" ? I mean, I can open a file explorer and look at the files, but no matter how much I concentrate on them they do not appear on the debugger :( |
I bring up Chrome developer tools, CTRL+O to open a file, search for the On Sun, Jun 1, 2014 at 3:28 AM, Manuel Astudillo notifications@github.com
-Judah Gabriel Himango |
The node-inspector readme says run 'node-debug _mocha', which automatically stops on the first line. |
... and then I put "debugger" in the files under test (FUT). I couldn't find a way to open my FUTs from within chrome either. CTRL-O doesn't list any files only those under the mocha folder. |
|
@bajtos thanks for getting back to me. I'm using |
@andrewroberts Do you happen to run on Mac OSX? In which case the keyboard shortcut is Cmd+O. Also when inside "Sources" tab, there is a small |
I see the file navigator but it only shows the folder tree below the _mocha file that it's stopped on, and CTRL-O (Linux Mint 14 with WIndows keyboard) only shows the tree below this. |
JudahGabriel, thank you! I've been trying here and there to figure out how to debug my app while tests are executing. Following the instructions provided in the node-inspector docs didn't do the trick. Your instructions however, worked perfectly. I can now step through my code while my tests are running making my workflow FAR more productive. Plus, it appears that I can go back to using mocha's --recursive option, allowing me to sanely organize tests. This is especially helpful since tests can't be placed throughout an app as far as I can tell. |
@bajtos Hello I'm developing a project with the block MEAN.JS and I have problems running the debug various file test.js that when I put the breakpoint generates errors that I can not "see" the module that loads the test. How can I solve this problem ?? :( Thanks! |
@Zacknero please provide a full code snippet, the example in your comment is not a valid mocha code. In general, you probably need to split your code into multiple lines, so that you can place the breakpoint inside the function body, as opposed to placing it on a line where the function is executed. |
(function() {
.................. to more and ApplicationConfiguration.applicationModuleName the variable is inside the file config.js |
The code is AngularJS code that you need to run in a browser, not via Node Inspector. If you are using Chrome Developer Tools to debug your test, then you can try to ask in Google Chrome Developer Tools. If you are using Karma Runner then you can try karma-users too. |
Thank you!! I'm going to get a better view of karma! |
Hi
Is it possible for mocha to work with node inspector ?
I tried with mocha -d, but this seemed to just give the node debug prompt.
weepy
The text was updated successfully, but these errors were encountered: