chai icon indicating copy to clipboard operation
chai copied to clipboard

lengthOf - comparing lengths of 2 arrays/objects is discouraging, lengthsEqual needed

Open 1aerostorm opened this issue 3 years ago • 0 comments

This code:

assert.equal(res.length, 5);

could be rewrote to:

assert.lengthOf(res, 5);

And it is short and graceful.


But this code:

assert.equal(res.length, res2.length);

could be rewrote only to:

assert.lengthOf(res, res2.length);

which occasionally causes mistakes with omitted or excessive ".length".

More consistent way is to rewrite it to:

assert.lengthsEqual(res, res2);

1aerostorm avatar May 08 '21 19:05 1aerostorm