question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

truncateThreshold should apply to more types or the documentation should be clarified

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
keithamuscommented, May 23, 2016

The plan is for loupe (our inspection lib) to truncate intelligently, based on the actual and expected. So if you had a trunaceThreshold of 10 the string foobarbazbing would render as 'fooba...', but if you compared foobarbazbing to foobazbingbar then the error message would be more like Expected '...ar...' to equal '...az...' (obviously 10 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.

0reactions
lucasfcostacommented, Jun 11, 2018

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found