简体   繁体   English

在WebStorm中使用Angular 2调试Karma / Jasmine测试

[英]Debugging Karma/Jasmine Tests with Angular 2 in WebStorm

I'm trying to debug my Angular 2 Tests in WebStorm (2016.3.2). 我正在尝试在WebStorm(2016.3.2)中调试Angular 2测试。 The first thing I tried was just to do it in Chrome Dev tools, but I actually don't see the script files in Sources to be able to set the break point. 我尝试的第一件事只是在Chrome Dev工具中执行此操作,但是实际上我看不到Sources中的脚本文件能够设置断点。 Note that you can see the script tags in the HTML page, but there's nothing in Sources. 请注意,您可以在HTML页面中看到脚本标签,但是Sources中没有任何内容。

Chrome开发人员工具捕获

So I did a bit more digging and found you can set up WebStorm to run and debug unit tests . 因此,我做了一些进一步的挖掘工作,发现您可以设置WebStorm来运行和调试单元测试

The tests do run, but the WebStorm breakpoint is never hit, and something seems to be "off" about what is happening. 测试确实可以运行,但是WebStorm断点从未触及,发生的事情似乎有些“偏离”。 Obviously, I haven't used WebStorm before to run or debug unit tests, so I don't know what normal looks like. 显然,我之前没有使用过WebStorm来运行或调试单元测试,所以我不知道它的正常外观。

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

I'm sure I'm just missing something, but with so many unfamiliar technologies coming together, I'm not sure what thread to pull. 我确定我只是缺少一些东西,但是由于有许多陌生的技术融合在一起,所以我不确定要拉什么线程。

I had edited my karma config file to include the ts files and the map files. 我已经编辑了业力配置文件,以包含ts文件和地图文件。 When I set them both to include=false and launch from the terminal with ng test, the Sources window looks more like this: 当我将它们都设置为include = false并使用ng test从终端启动时,“源”窗口看起来像这样: Chrome开发工具

This is what I was seeing before, but it confused me because I was expecting to see my own files. 这是我以前看到的内容,但它让我感到困惑,因为我希望看到自己的文件。 However, if I search in that file, I find my own code: 但是,如果我搜索该文件,则会找到自己的代码: 我在test.ts文件中的代码

It still doesn't stop on the break point, but it's a start. 它仍然不会在断点处停止,但这是一个开始。

When I try to debug it through Webstorm, it still is seeing the Mime type as video/mp2t, so I'm guessing that it is interfering somehow with the Mime Types set up in the Karma config file. 当我尝试通过Webstorm调试它时,它仍然将Mime类型视为video / mp2t,因此我猜测它会以某种方式干扰Karma配置文件中设置的Mime类型。

I find myself wondering if the devs working on this Framework build anything other than Frameworks, since at every turn it seems like they've erected huge, unnecessary barriers to actually seeing what's going on in your app. 我发现自己想知道开发此Framework的开发人员是否会构建除Frameworks之外的其他任何东西,因为在任何情况下,他们似乎已经竖起了巨大的不必要的障碍来实际查看应用程序中发生的事情。

Update: 更新:

It looks like this is a bug that comes and goes in Angular-CLI. 看来这是Angular-CLI中的一个错误 Seems to be in the "comes" phase today. 今天似乎处于“进入”阶段。

Update 2 更新2

You can find the files in the webpack:// folder that's next to the localhost://folder. 您可以在localhost://文件夹旁边的webpack://文件夹中找到文件。 It's logical to think that the files you need will be in the apparent site root, but they're not. 逻辑上认为您需要的文件将位于明显的站点根目录中,但事实并非如此。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM