简体   繁体   English

Angular,Karma和Jasmine报告颜色

[英]Angular, Karma and Jasmine report colors

I am setting up a new solution with Angular 6, Karma and Jasmine. 我正在与Angular 6,Karma和Jasmine建立一个新的解决方案。 However to my surprise the specs list is getting the following class as undefined: 但令我惊讶的是,specs列表将以下类定义为undefined:

<li class="undefined" id="spec-spec1" spec-suite-id="suite3">
<a href="?spec=Router%3A%20App%20looks%20async%20but%20is%20synchronous">
   looks async but is synchronous
</a>
</li>

在此输入图像描述

Using Angular 5 the result looks as follows: Specs that are running are clearly shown in green and skipped spec are shown in grey 使用Angular 5时,结果如下所示:正在运行的规格清晰显示为绿色,跳过的规格显示为灰色

在此输入图像描述

How to debug this in Angular 6 generated test using CLI ? 如何使用CLI在Angular 6生成的测试中调试这个?

you can write console.log to write logs into the console or directly write "debugger" in your test and open the developer console of the browser you run the test in. 您可以编写console.log来将日志写入控制台,或直接在测试中编写“debugger”并打开运行测试的浏览器的开发人员控制台。

Always run only the test where the problem is. 始终只运行问题所在的测试。 To do this you can focus on a test with "f" bevore describe() and it() so only this test is executed. 为此,您可以专注于使用“f”bevore describe()和it()的测试,因此只执行此测试。

fdescribe("when ...", function () { // to [f]ocus on a single group of tests
    fit("should ...", function () {...}); // to [f]ocus on a single test case
});

... and: ......和:

xdescribe("when ...", function () { // to e[x]clude a group of tests
    xit("should ...", function () {...}); // to e[x]clude a test case
});

As you see you are using old version of Karma (1.7.1). 如您所见,您正在使用旧版本的Karma(1.7.1)。 Update it in package.json (with other dependencies like jasmine-core). package.json中更新它(与其他依赖项如jasmine-core)。 Currently last version is 4.1.0 - you can check it at https://www.npmjs.com/package/karma 目前最新版本是4.1.0 - 您可以在https://www.npmjs.com/package/karma查看

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

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