问题描述
我有Java开发背景,可以在SourceCode中使用断点并运行UnitTests来达到目标。我现在在Angular / Typescript环境中尝试相同的操作,但是我只能在测试代码中遇到断点。
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.
源代码:
1) export class SomeClass {
2) someMethod() {
3)* doit;
4) }
5) }
- 断点未命中
测试代码:
1) describe('SomeClass', () => {
2) it('test someMethod()', () => {
3) SomeClass someClass = new SomeClass();
4)* someClass.someMethod();
5) }
6) }
- 断点命中
- 开始我的浏览器上的业力:
http:// localhost:9876 /
- 点击右侧的debug选项,或者直接转到
http:// localhost:9876 / debug.html?
- 然后在调试内打开调试器,并在$中添加断点b $ b代码和/规范
我首选的编辑器是Visual Studio Code,但如果在IntelliJ / Webstorm IDE中也可以使用,我也很高兴。
My preferred editor is Visual Studio Code but I'm also happy if this would work in IntelliJ/Webstorm IDE.
软件包版本为:
-Angular 5.2.5
-茉莉2.8.0
-茉莉花核心2.8.0
-业力3.0.0
-业力铬启动器2.1.1
-业力1.0.1
-因果茉莉1.1.1
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
推荐答案
我的操作方式是运行测试是watch: ng test --watch true
然后添加调试
The way i do it, is I run my test is watch : ng test --watch true
and then add a debug
这篇关于运行UnitTest时调试源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!