Ease debugging Node.js from within VSCode #9510
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The other day my Chrome browser (dev channel) started crashing spontaneously on startup, which kept me from using the Chrome DevTools to debug Apollo Client tests running in Node.js.
Since I mostly use VSCode for editing these days, I decided to see if I could debug Node.js from entirely within VSCode. After all, a VSCode frontend for the V8 debugging protocol is advertised here. This would be appealing not just as a backup for Chrome, but also because it allows setting temporary breakpoints in source files (as well as inspecting local variables and the call stack) without leaving VSCode.
So far this experiment has worked out quite nicely, so this PR shares my VSCode configuration for this repository, for anyone else who wants to try this style of debugging.
Steps:
debugger
statements or VSCode breakpoints (click the red dot at the far left of any line)npm run test:debug
, ornpm run test:debug src/cache/inmemory
to scope which tests are runAttach to Node.js inspector
from the drop-down menu towards the top, and press the green triangle to start debuggingjest.js
)