Debug Source Code while Running UnitTests

烂漫一生 提交于 2019-12-13 04:28:35

问题


I have a background as Java dev and there I could use breakpoints in my SourceCode and run UnitTests to hit them. I'm trying the same now in an Angular/Typescript environment but I can only hit breakpoints in my test code.

Source Code:

1) export class SomeClass {
2)   someMethod() {
3)*    doit;
4)   }
5) }
  • Breakpoint not hit

Test Code:

1) describe('SomeClass', () => {
2)   it('test someMethod()', () => {
3)     SomeClass someClass = new SomeClass();
4)*    someClass.someMethod();
5)   }
6) }
  • Breakpoint hit

My preferred editor is Visual Studio Code but I'm also happy if this would work in IntelliJ/Webstorm IDE.

The package versions are:
- Angular 5.2.5
- jasmine 2.8.0
- jasmine-core 2.8.0
- karma 3.0.0
- karma-chrome-launcher 2.1.1
- karma-cli 1.0.1
- karma-jasmine 1.1.1


回答1:


The way i do it, is I run my test is watch : ng test --watch true and then add a debug

  • Start karma on my browser: http://localhost:9876/
  • hit the debug option on the right or, directly got to http://localhost:9876/debug.html?
  • then, inside the debug open the debugger, and add breakpoints in the code and/spec


来源:https://stackoverflow.com/questions/53167832/debug-source-code-while-running-unittests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!