本文介绍了格式化chai.expect错误中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当测试失败时,我要使用expect(x).to.deep.equal(y)比较两个对象,我想在浏览器测试报告中查看实际值.相反,我看到这样的东西:

When test fails, where I'm comparing two objects using expect(x).to.deep.equal(y), I'd like to see the actual values in my browser test report. Instead, I see something like this:

AssertionError: expected { Object (x, y, ...) } to deeply equal { Object (x, y, ...) }

因此它并没有真正显示出有用的信息.

So it doesn't really show anything useful.

是否可以自定义chai.js如何格式化这些对象?

Is there a way to customize how chai.js formats these objects?

推荐答案

您现在可以按照文档:

chai.config.truncateThreshold = 0; // disable truncating

这篇关于格式化chai.expect错误中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 14:59