NG 测试中的调试测试 [英] Debug Tests in NG Test
问题描述
我正在使用 Angular CLI 和 VSCode,但是当我运行 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
?
我需要做一些配置吗?
推荐答案
Angular 9 版更新
源文件已被移动,但如果您执行以下步骤,您仍然可以通过这种方式进行调试
The source files have been moved but you can still debug this way if you do the following steps
- 在 devtools 中,选择源标签
- 按 CTRL + P
- 输入要调试的文件名
适用于 9 以下的版本
其他答案是完全有效的答案,但我已经使用 Angular 大约 18 个月了,我倾向于在浏览器中使用 - chrome 工具!
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!
运行 ng test 然后 f12 并通过 webpack 上下文找到规范文件.添加断点并刷新,它将命中所述断点.根据截图
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
这篇关于NG 测试中的调试测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!