业力/茉莉花控制台更详细的测试结果 [英] karma/jasmine console more detailed test results

查看:224
本文介绍了业力/茉莉花控制台更详细的测试结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Karma与茉莉花为我的JavaScript单元测试。
假设我有一个失败的测试,像这样:

  expect(objectA).toEqual(expectedObjectA); 

当它失败时,我看到两个对象倾倒在控制台上,一条消息告诉我对象是不等于:



这不是很有帮助,因为为了找出它们不相等的原因,我必须从控制台复制粘贴文本,从对象转储中分离两个对象,格式化他们,把他们在一个差异编辑器。 (有时候,即使这样做也没有帮助,因为对象是不平等的,因为他们有成员是功能)。



有没有办法让茉莉花转储到控制台的第一个属性的不同之间的两个对象的确切名称和价值?

有没有办法看到对象转储漂亮的打印? (并不是真的有必要,但是它比这个不可读的转储更好)。看起来你可能需要一个自定义的匹配器。
您有没有看过这个问题? 茉莉花toEqual复杂的对象(混合功能)


I'm using Karma with Jasmine for my javascript unit tests. Suppose I have a failing test like this:

 expect(objectA).toEqual(expectedObjectA);

When it fails, I see the two objects dumped on the console and a message telling me the objects are not equal:

This is not very helpful because in order to find out why they are not equal, I have to to copy paste the text from the console, split the two objects from that object dump, format them, put them in a diff editor. (Sometimes even that doesn't help because the object are not equal because they have members which are functions).

Is there a way to make jasmine dump to the console the exact name and value of the first property that differs between the two objects?

Is there a way to see the object dump pretty printed? (not really necessary, but it would be nicer than this unreadable dump)

解决方案

Looks like you may need a custom matcher.
Have you had a look at this question ? Jasmine toEqual for complex objects (mixed with functions)

这篇关于业力/茉莉花控制台更详细的测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆