chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.13k stars 699 forks source link

Allow configuring inspection depth #1352

Open ghost opened 4 years ago

ghost commented 4 years ago

Right now, pretty-printing of objects is hard-coded to stop at a depth of 2. There already is a configuration of the truncation threshold for the length of the string via config.truncateThreshold, but this depth of 2 cannot be configured; even with config.truncateThreshold = 0, objects will not be printed beyond a depth of 2 properties.

It would be nice to be able to configure this (or disable entirely) via a property like config.recurseThreshold.

tennox commented 3 years ago

There is an monkey-patch answer describing how to override the formatting method: https://stackoverflow.com/a/28652362/1633985

which I also put into an npm package (yes, I'm a bit ashamed myself):
https://github.com/TeNNoX/chai-formatter-monkeypatch