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.

Comparing Buffers produces massive test output

See original GitHub issue

E.g.

fs.readFileSync("expected.png").toString()
    .should.equal(fs.readFileSync("actual.png").toString());

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
logicalparadoxcommented, Oct 11, 2012

Just FYI - You are going to want to leave them as buffers and use .deep.equal.

var actual = fs.readFileSync('actual.png')
  , expected = fs.readFileSync('expected.png');
actual.should.deep.equal(expected);

If two buffers are provided, deep equal will do a byte-to-byte comparison. Though, admittedly, it will still likely produce a huge output.

Back on topic…

Could add more types here? https://github.com/chaijs/chai/blob/master/lib/chai/utils/objDisplay.js#L38

0reactions
keithamuscommented, Dec 17, 2015

Yup @lucasfcosta you’re totally right!

> chai.expect(new Buffer(crypto.randomBytes(1000))).to.deep.equal(new Buffer(crypto.randomBytes(1000)))
AssertionError: expected <Buffer 87 a2 9b d0 34 be a0 30 bb 8a 44 29 e1 b3 e1 66 ca 14 67 dd e1 8e 4c d1 84 0d f5 25 c3 fb 87 6a 46 e8 28 cc 8d 99 7a b2 86 7b 36 75 25 02 4f 0c b4 35 ... > to deeply equal <Buffer 29 c3 4d e7 32 95 7c 5c a8 74 2a 2a 1e 4b fe 3e 0b 01 3d 58 e8 d5 df 60 31 d3 b3 86 da 66 cb fb c1 e8 4b 28 d2 df 06 b5 be 15 8b e1 1c 3e 14 3f 22 76 ... >

I’ll close this one for now as I think there’s nothing more that needs doing. If anyone sees any more problems with this, please file a new issue 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chemistry of buffers and buffers in our blood - Khan Academy
So, in order to be an effective buffer,. The number of moles of the weak acid and its conjugate base must be significantly...
Read more >
8.9 Buffer Capacity and Buffer Range - Chemistry LibreTexts
Buffers are characterized by the pH range over which they can ... NaOH to 100.0 mL of distilled water results in a very...
Read more >
Test Results Compare Buffer Seals for Hydraulic Cylinders
Tests check the two most common buffer seals to determine what applications each is best suited for.
Read more >
Lab 7 - Buffers - WebAssign
The salt, if added to the weak acid solution, produces a large amount of formate ion in comparison to that produced by the...
Read more >
Chem 131A: pH and Buffers Experiment
The last section of the experiment involves the preparation of a buffer and an examination of buffer capacity. One of the most frequent...
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