microsoft / vscode-recipes

MIT License
5.87k stars 578 forks source link

npm run test (ng test) "Breakpoint set but not yet bound" Angular CLI #240

Closed lakartoza closed 3 years ago

lakartoza commented 5 years ago

I can't debug my tests following the instructions on Angular CLI.

When I run my "ng test" launcher, my breakpoints say "Breakpoint set but not yet bound".

1) Debugging works with my chrome browser if I initiate my breakpoint on my Chrome dev tools. 2) ng serve debugging works fine.

Context:

Does anyone else have this issue?

lakartoza commented 5 years ago

I followed through the issues #175 and #585. I have had no luck...

My .scripts point to the correct files. If I click the link that comes from .scripts , VS Code will opens up the instance of that file, "c:\Users.......{workspace}\src\app.component.spec.ts" and the breakpoint works there. So it's like pointing to the right place, but the break points don't hit when I use it from ng test.

Some help would be very much appreciated.

Dschuli commented 4 years ago

Same here - breakpoints are set okay (full red dots) , but as soon as I start the debug run, they become unbound (white/hollow) and do not get hit. Tried variations (as proposed) of the debug configuration, but without success.

CwjXFH commented 4 years ago

I had the same problem.

cwistedt commented 4 years ago

I have the same problem. Tried bunch of different solutions without any luck.

brutuscat commented 4 years ago

@chrisdias any luck making this work?

NCARalph commented 4 years ago

Same problem.

tasdevani21 commented 4 years ago

It might be related to the Path mapping to the launch file being missing. Just add this line along with the instructions found in the Angular CLI for the ng test. I also opened a issue here which explain it a little more: Unit Test Issue

      "pathMapping": {
        "/_karma_webpack_": "${workspaceFolder}"
      }
CwjXFH commented 4 years ago

@tasdevani21 I tried, but it doesn't work.

maxdavidguenther commented 4 years ago

@tasdevani21 idea led me to the right solution. Add this path mapping to your launch.json:

"pathMapping": {
  "/_karma_webpack_": "${workspaceFolder}"
}
thismat commented 4 years ago

@tasdevani21 brilliant. You just saved me so much frustration tonight. Thanks!

Rajesh5496 commented 4 years ago

@tasdevani21 i added the snippet to launch.json but still code doesn't stop at breakpoint. it says Breakpoint set but not yet bound

rami-alloush commented 4 years ago

This answer here seems to be working fine with latest updates. Your launch.json should be as follows

{
   "type": "chrome",
   "request": "launch",
   "name": "Launch Chrome",
   "url": "http://localhost:4200",
   "webRoot": "${workspaceFolder}",
   "sourceMaps": true,
   "sourceMapPathOverrides": {
       "/./*": "${webRoot}/*",
       "/src/*": "${webRoot}/*",
       "/*": "*",
       "/./~/*": "${webRoot}/node_modules/*"
    }
}
connor4312 commented 3 years ago

duplicates Duplicates https://github.com/microsoft/vscode-recipes/issues/225