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.
Is there a way to customize how chai.js formats these objects?
Note expect and should uses chainable language to construct assertions, but they differ in the way an assertion is initially constructed. In the case of should , there are also some caveats and additional tools to overcome the caveats. var expect = require('chai').
expect , should = chai. should(); The expect interface provides a function as a starting point for chaining your language assertions. It works on node. js and in all browsers.
Chai is such an assertion library, which provides certain interfaces to implement assertions for any JavaScript-based framework. Chai's interfaces are broadly classified into two: TDD styles and BDD styles.
Chai assertion library is an external javascript library used to write assertions. Compared to what we write directly in javascript, this assertion library needs less time & effort and easy use. Chai assertion library is available by default in the Postman.
You can now configure the max length before an object gets truncated as per the docs:
chai.config.truncateThreshold = 0; // disable truncating
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With