Debugging javascript using built in chromium debugger


#1

Hi guys :smile:,

I am trying to find a way how to debug any js or maybe even coffee file I open in Atom using built in debugger. It is easy to debug package code, but I can’t make debugging of any file work.

Am I missing something?


#2

Isn’t this a duplicate of your earlier question? I thought you had some definitive answers. Mine was especially good. (grin)


#3

Yes :slight_smile: I just wanted to be sure, frankly I am was bit surprised not to find this functionality. I mean it works for packages. I am curious if there is any plan to integrate it.


#4

The thing is that to debug code in chromium you have to make it run in it, so it’s not that simple to debug any file with it.
I’m not sure to see how one can just open a file and debug it without having a scenario that covers all the possible use of the code in the file. Have you some concrete use case in mind?


#5

Hi @abe, good question.

Maybe for the start it would be ok to debug just one simple js files? In future maybe whole nodejs projects? I am not really familiar with implementing debugger so I am curious about possibilities too.


#6

Let’s take a quick example:

Here’s a file dummy.coffee:

module.exports = 
class Dummy 
  constructor: (options={}) -> 
     if options.foo 
       @foo = options.foo
     else 
       @foo = 'bar'

Actually running this file in chrome or in node won’t allow you to debug what’s going on in the class constructor or in any other method of the class or instances. To reach the constructor inner code you’ll have to run new Dummy at some point. This is what I mean by scenario. Debugging is only possible for code that run.

Code coverage is a good example of this problem. To reach 100% coverage means that you don’t have a single line of code, a single branch that doesn’t run in the tests. So that mean that you have to write test that actually reach every branches, every lines in the code.

Given that reaching 100% coverage with tests is a pretty huge task to the person that write the tested code, I don’t see how an automated process could do the same.

I think this is a problem linked to static analysis of code. But I’m not knowledgeable enough on that matter to further elaborate.


#7

I think making an external atom package maybe a better choice. There’re few reason cross over my mind are:

  1. Nodejs/iojs version
  2. Custom debugging arguments
  3. Custom node/iojs running arguments
  4. Custom environments variables