New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deep.equal() and deep.include() doesn't work with Error #1009
Comments
Thanks for the issue @marian-r. The behavior of The behavior of |
@meeber does this fixes it? function include (val, msg) {
if (msg) flag(this, 'message', msg);
_.expectTypes(this, [
'array', 'error', 'object', // added error here
'string', 'map', 'set',
'weakset'
]);
var obj = flag(this, 'object')
, objType = _.type(obj).toLowerCase();
// This block is for asserting a subset of properties in an object.
if (objType === 'object' || objType === 'error') { // added error here
var props = Object.keys(val)
, negate = flag(this, 'negate')
, firstErr = null
, numErrs = 0;
....
.... |
@vieiralucas Yup that fixes the problem for error objects. I'm just wondering if the way we're using type-detect here will cause problems for other types of objects, particularly custom objects. |
I've had the same issue with Real code (GitHub diff): Simplified example: expect({ a: 1 }).to.include({ a: 1 }) // pass
expect({ a: 1, [Symbol.toStringTag]: "foo" }).to.include({ a: 1 }) // fail I believe we should not special-case |
@meeber thanks and sorry I haven't seen notifications before. I will try the fix tomorrow. |
@meeber I confirm that the fix for |
deep.equal()
anddeep.include()
doesn't compare the object keys as I expect it to. I found the issue when upgrading to v4 as thedeep.equal()
works fine in v3.5. It stopped working in v4+.Here is a code to confirm the issue: https://jsfiddle.net/wLzrucae/3/.
I tried adding
error
to the allowed types forinclude()
assertion, but it still failed on comparison. Any ideas?The text was updated successfully, but these errors were encountered: