truncateThreshold should apply to more types or the documentation should be clarified
See original GitHub issueThe docs on truncateThreshold currently state:
config.truncateThreshold
@param {Number}
@default 40
User configurable property, sets length threshold for actual and expected values in assertion errors. If this threshold is exceeded, the value is truncated.
Set it to zero if you want to disable truncating altogether.
chai.config.truncateThreshold = 0; // disable truncating
The first statement is not strictly true because truncateThreshold only applies to objects, arrays and functions. For example:
chai.config.truncateThreshold = 10;
chail.assert.equal('fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo', 'foo');
// Results in:
AssertionError: expected 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' to equal 'foo'
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
format - Go Packages
TruncateThreshold (default 50) specifies the maximum length string to print in string comparison assertion error messages. View Source var TruncatedDiff = true.
Read more >Assertion Styles - Chai
Assertion Styles. This section of the guide introduces you to the three different assertion styles that you may use in your testing environment....
Read more >PeopleSoft Enterprise General Ledger 9.1 PeopleBook
See Enterprise PeopleTools 8.5x PeopleBook: PeopleSoft Application Engine, ... You should create the non-shared table from existing non-share tables rather ...
Read more >Chai - GitHub Pages
#561 (docs) Added JSDocs to 'should' interface. ... .to.be.a('type') has changed to support more types, including ES6 types such as 'promise' , 'symbol' ......
Read more >DRAGEN User Guide - Amazon S3
This command will load the binary reference genome into memory on the DRAGENTM ... Where there are differences, the graph forms “bubbles” of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The plan is for loupe (our inspection lib) to truncate intelligently, based on the
actual
andexpected
. So if you had atrunaceThreshold
of10
the stringfoobarbazbing
would render as'fooba...'
, but if you comparedfoobarbazbing
tofoobazbingbar
then the error message would be more likeExpected '...ar...' to equal '...az...'
(obviously10
is not a very practical truncate threshold but it illustrates the point of showing only the differences).The idea behind this is that truncateThreshold will A) really truncate to the specified length and B) give you better, richer, more relevant information when truncated.
Edit: It should also be pointed out that there is still a lot of figuring out on how to do this the right way, and we’ll be making sure we don’t end up making error messages less usable - just removing crufty information that is not needed.
Hi @Joris-van-der-Wel, thank you very much for this issue! 😄
Recently we have been adding our priorities to a
roadmap
board and referencing issues there to make sure we’ll get things done in a better and more organised way.Your suggestion is much appreciated and we’ll certainly take it into account when refactoring
loupe
.For now, I’ll close this in order for us to get a clean slate to work on.
Thank you very much!