0

I'm using angular2 cli and am following the test debugging instructions here official documentation. I'm able to search for the spec.ts source files which are in the app folder and set break points. However, I'm not able to do the same for the test files for components in other folder. The tests do run but I'm not able to find the source file in the chrome browser. Shall I edit some config file? I've tried to add the source files manually to the source in chrome but that doesn't help in setting the breakpoint. Any help is very much appreciated.

1 Answer 1

2

Do this and see what happens:

  • In a test that you cannot find, add a debugger; statement
  • Run ng test
  • When Karma is loaded in a new browser window, click the "Debug" button
  • Open the developer tools as soon as a new tab is opened in Chrome (reload the tab if you do this late)

See the "Source" devtools tab open to the file and break on the debugger statement. This should be the answer to your question.

Sign up to request clarification or add additional context in comments.

1 Comment

I guess that's not how we're supposed to debug unit tests, but considering that I wasted many hours trying to debug my code, your tip is absolutely brilliant!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.