You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following from chaijs/chai#469 - we should be able to use loupe() to have a shallow inspection on different properties of a value (but without becoming a full diffing engine). To quote my own words in chaijs/chai#469:
There is another part of the puzzle though, and that's chai's inspection engine. The message which says 'AssertionError: expected [ Array(2) ] to deeply equal [ Array(2) ]' is from Chai, and we use our own inspection library (found here) to create these.
I think here we have a lot of room to make things better. [ Array(2) ] isn't that useful, [ [1, 2] ] would be more useful I'm guessing - but we need to strike a good balance between too much info and too little.
Can I suggest we move the topic of conversation on how to deal with these small arrays and objects within messages? Here's the code for formatting Arrays - we could place in some length checks and try to output the full contents of short Arrays, or truncate them in the middle and only show [0..2, n-2..n].
I think we could go further, because we have knowledge about the actual and expected properties - that we could supply to loupe to generate more interesting inspection strings from within loupe, for example:
// Inspecting a standard value.loupe({foo: 1,bar: 1,baz: 1})==='{ foo: 1, bar: 1, baz: 1 }';// Inspecting a value with a comparison value, to generate a better representation of the first object:varactual={foo: 1};loupe({foo: 1,bar: 1,baz: 1},{diff: actual})==='{ ... bar: 1, baz: 1 }';
The example above isn't the most clear - because the benefit isn't really properly demonstrated on such small objects, but imagine objects or TypedArrays or Buffers which have hundreds of values and we just show a very poor representation without giving useful info about them:
Following from chaijs/chai#469 - we should be able to use loupe() to have a shallow inspection on different properties of a value (but without becoming a full diffing engine). To quote my own words in chaijs/chai#469:
I think we could go further, because we have knowledge about the
actual
andexpected
properties - that we could supply toloupe
to generate more interesting inspection strings from withinloupe
, for example:The example above isn't the most clear - because the benefit isn't really properly demonstrated on such small objects, but imagine objects or TypedArrays or Buffers which have hundreds of values and we just show a very poor representation without giving useful info about them:
The text was updated successfully, but these errors were encountered: