Reputation:
The test below should fail, but it is passing:
it('should fail', () => {
const actual = new Set('a');
const expected = new Set('b');
expect(actual).toEqual(expected);
});
I'm using the expect
package from npm. I'm using Babel 5 to use Set. I'm using Node 5, so the Set being used should be native.
Am I doing something wrong, or does this look like a bug in the expect
package in the way it handles Sets? I've cross posted an issue on the package as I'm not sure.
Upvotes: 2
Views: 469
Reputation: 19337
expect
depends on deep-equal
, which does not support sets and maps.
This in consistent with the behavior of node's assert
:
var a = new Set('a');
var b = new Set('b');
console.log(require('assert').deepEqual(a, b) || 'ok');
// Prints 'ok' !
This issue has been discussed here :
assert: add support for Set and Map
This comment is particularly interesting :
I don't think we should do this (or anything else in #2309). Assert should remain used only for testing io.js itself, and not try to be a good general assertion library. If io.js tests need this ability enough times that we need to factor it out, we should, but until then, just adding it because it'd be nice isn't a good idea IMO.
You can either:
Upvotes: 2