Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Tests in NG Test

I am using Angular CLI and VSCode but none of my breakpoints in my spec files seem to be getting hit when I run ng test?

Do I need to do some config?

like image 633
72GM Avatar asked May 11 '17 13:05

72GM


People also ask

How do you debug Jasmine test?

The Jasmine test runner is just another web page made with HTML, CSS and JavaScript. This means you can debug it in the browser using the developer tools. Focus the browser window and open the developer tools. In Chrome, Firefox and Edge, you can use the F12 key.

How do I debug a test in VS Code?

Once you have your launch configuration set, start your debug session with F5. Alternatively, you can run your configuration through the Command Palette (Ctrl+Shift+P) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug.


1 Answers

Update for Angular version 9

The source files have been moved but you can still debug this way if you do the following steps

  • In devtools, select the sources tab
  • Press CTRL + P
  • Type in the name of the file you want to debug

enter image description here

Valid for versions below 9

The other answers are completely valid answers but having been using Angular for around 18 months now I tend to do it in the browser - chrome tools!

Run ng test then f12 and find the spec file via the webpack context. Add a breakpoint(s) and refresh and it will hit said breakpoints. As per screenshot

enter image description here

like image 152
72GM Avatar answered Sep 21 '22 18:09

72GM