caolan / caolan/nodeunit

deepEqual not Usable on Buffers

Open
#141 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
359
PR merge metrics
No merged PRs in 30d

Description

Using nodeunit 0.6 on node 0.4.12 (and others), the following test:

```
exports.test = function (test) {
var a = new Buffer([0]), b = new Buffer([0]);
test.deepEqual(a, b);
test.done();
};
```

Fails with:

```
test
✖ test

AssertionError: deepEqual
at Object.deepEqual (/home/smith/nu/node_modules/nodeunit/lib/types.js:83:39)
at Object. (/home/smith/nu/test.js:3:10)
at Object. (/home/smith/nu/node_modules/nodeunit/lib/core.js:233:16)
at /home/smith/nu/node_modules/nodeunit/lib/core.js:233:16
at Object.runTest (/home/smith/nu/node_modules/nodeunit/lib/core.js:69:9)
at /home/smith/nu/node_modules/nodeunit/lib/core.js:115:25
at /home/smith/nu/node_modules/nodeunit/deps/async.js:508:13
at /home/smith/nu/node_modules/nodeunit/deps/async.js:118:13
at /home/smith/nu/node_modules/nodeunit/deps/async.js:134:9
at /home/smith/nu/node_modules/nodeunit/deps/async.js:507:9
```

This test passes with nodeunit 0.4. It would be nice if deepEqual, or some method, worked to compare Buffers.

This is used on https://github.com/cramerdev/gearman-node/blob/master/test/test-packet.js, among other places.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at lib/types.js:83, where the failing deepEqual assertion is reported, and reproduce the issue with the Buffer example from the report. Add a regression test for two equal Buffers and verify that deepEqual accepts them while still reporting unequal Buffers correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.