Skip to content
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

Add debugger support #70

Merged
merged 3 commits into from
Jul 7, 2016
Merged

Add debugger support #70

merged 3 commits into from
Jul 7, 2016

Conversation

inukshuk
Copy link
Collaborator

@inukshuk inukshuk commented Jul 6, 2016

Somewhat related to #68 this adds debugger support.

By default, Electron sees our command line switches, so passing --debug or --debug-brk is actually handled by Electron. This PR adds both switches to our options list to make sure that we don't halt because these options were passed (but we don't do anything with them).
#68 was asking for VS Code support -- this could probably be made to work using the debugger protocol but we can't implement this kind of integration in electron-mocha.

Instead, this PR adds a way to debug renderer tests using the built-in debugger. When you run the tests with --renderer-debug we will show the test runner window and open the dev-tools; futhermore, in my testing I noticed that there is a slight delay until the debugger is ready, so we delay running the tests a little bit. That is to say, if you don't do anything else this option will run your tests as usually, but with a slight delay and the window will show up while the tests are running. But the cool thing is: if you add a debugger statement anywhere in your tests or in your code the debugger will break once it reaches that statement.

Additionally, this adds a --renderer-debug-brk which will break right in the renderer just before mocha will start.

@jprichardson what do you think?

@jprichardson
Copy link
Owner

I think this is a great idea!

I'm not keen on the additional flags for the renderer. It seems like it could be confusing for new users. As I understand it, the need for the additional flags for the renderer is to actually show the renderer window... and the dichotomy of 'main' or 'renderer' is something that new users would have to understand anyways. So maybe the extra flags are unavoidable?

That being said, I support the changes here.

@inukshuk
Copy link
Collaborator Author

inukshuk commented Jul 7, 2016

Yeah, I was not happy about adding the separate renderer flags either, but the rationale was that you might want to enable the dev-tools debugger without also enabling the debugger in electron. This is especially true for --debug-brk since you'd have to attach a debugger to actually continue executing.

What we could do is, remove the --renderer-debug-brk and --renderer-debug options and interpret --debug like --renderer-debug, i.e., open dev-tools debugger in renderer. This would mean that we lose the current --renderer-debug-brk functionality which is no big deal.

@inukshuk
Copy link
Collaborator Author

inukshuk commented Jul 7, 2016

OK I removed the --renderer-debug* options. This is a tad less flexible, but it's much easier to use and just be a big help when debugging issues in your unit tests.

@inukshuk inukshuk merged commit 4a8a082 into master Jul 7, 2016
@inukshuk inukshuk deleted the debugger branch July 7, 2016 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants