Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With mocha/chai how can i make it show lines skipped?

I have a failing unit test that is comparing two large arrays, and the output from mocha is partially skipped.

         "Qualifying/Commissions/Amount"
         "Qualifying/Other/Amount"
         "Qualifying/Overtime/Amount"
         "Qualifying/Total/Amount"
      -  "Factors/De/ ... Lines skipped
      +  "Factors/De/Base/Amount"
      +  "Factors/De/Bo ... Lines skipped

How do I get more of the lines that were skipped? Pytest has a -v option for verbose.

This is the result of calling

expect(actual).to.deep.equal(expected)

where actual and expected are big ol' arrays of strings.

Versions:
"mocha": "^9.0.3",
"sinon-chai": "^3.5.0",
"chai": "~4.1",

like image 549
J B Avatar asked Oct 30 '25 13:10

J B


1 Answers

If you see this you need to update mocha to at least v9.2.1 and then you can use --reporter-option maxDiffSize=0

From the docs:

New in v9.2.1

By default strings are truncated to 8192 characters before generating a diff. This is to prevent performance problems with large strings.

It can however make the output harder to interpret when comparing large strings. Therefore it is possible to configure this value using --reporter-option maxDiffSize=[number].

A value of 0 indicates no limit, default is 8192 characters.

like image 166
stefreak Avatar answered Nov 02 '25 02:11

stefreak