Unable to use breakpoints to debug TypeScript in Visual Studio Code.
See original GitHub issueIssue
I’m unable to debug Jest test cases written in TypeScript. Possibly just a configuration problem? What am I missing? Thanks!
Steps to reproduce
- Install Visual Studio Code. I tested with version 1.11.2
- Install Node.js. I tested with 7.8.0.
- Clone the repo here
- run
npm install
oryarn
- Set breakpoint on line 6 of
SystemUnderTest.spec.ts
. (Just abovedebugger;
statement) - Set breakpoint on line 3 of
SystemUnderTest.ts
. (Insideconstructor
). - Press F5 or click “Start Debugging”.
Expected Behavior
Debugger should stop…
- On line 6 of
SystemUnderTest.spec.ts
. - On line 3 of
SystemUnderTest.ts
. - On line 7 of
SystemUnderTest.spec.ts
.
Actual Behavior
Debugger only stops on line 7 of SystemUnderTest.spec.ts
Additional observations
debugger
statements stop in the proper location in the TS files, not in the transpiled JS, so sourcemaps are being emitted and consumed.
Once stopped, VS Code debug controls (e.g. F10 to step over) work fine.
VS Code reports that the breakpoints are loaded. They are not greyed out.
However, as the debugger reaches each expected breakpoint but doesn’t it it, it will begin reporting a source map problem.
The “future” breakpoint (line 8 of SystemUnderTest.spec.ts
) does not report any sourcemap problem.
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (5 by maintainers)
Top Results From Across the Web
Visual Studio code breakpoint not working on Node.js using ...
1 Answer 1 · Add the start script to package.json · click on the debug menu icon on the left side navigation menu....
Read more >TypeScript debugging with Visual Studio Code
Whenever you set a breakpoint in the original source, VS Code tries to find the generated source by searching the files specified by...
Read more >Debug Typescript Not Stopping on Break Points - Electron
I am attempting to debug an electron app written in Typescript and compiled to JS/sourcemaps with gulp and debugged with VSCode.
Read more >Debug a JavaScript or TypeScript app - Visual Studio (Windows)
You can debug JavaScript and TypeScript code using Visual Studio. You can hit breakpoints, attach the debugger, inspect variables, view the call ...
Read more >TypeScript Debugging Inside VSCode
In order to do that we need to have mappers, that map our TS files to the JS ones, and using those mappers...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hours spent on issues like that make me proud to be a software engineer. Bill Burr + Louis C.K. and still can’t laugh as loud. I’m also going to like my own comment for the added effects
@netpoetica Here’s mine, which I use on this project I use a separate jest config for debugging. launch.json
tasks.json
Relevant related files are here: package.json jest.debug.json tsconfig.debug.json Hope this helps!