Skip to content
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

DeepEqualExcludingEvery isn't working properly on deeply nested Date Objects #54

Open
ThomasDenoncin opened this issue Jan 21, 2025 · 0 comments

Comments

@ThomasDenoncin
Copy link
Contributor

ThomasDenoncin commented Jan 21, 2025

Hey !

I noticed an issue with the deepEqualExcluding function.
Deeply nested date objects are not compared properly.
Here is my test case, with all tests should be failing :

import { assert, use } from 'chai';
import chaiExclude from 'chai-exclude';

use(chaiExclude);

describe('deepEqualExcludingEvery', () => {
    const today = new Date();
    const oldDay = new Date('1970-01-01T00:00:00.000Z');

    it('should compare two objects', () => {
        assert.deepEqualExcluding({ date: today }, { date: oldDay }, []);
    });
    it('should compare two arrays of objects without props', () => {
        assert.deepEqualExcludingEvery([{ date: today }], [{ date: oldDay }]);
    });
    it('should compare two arrays of objects', () => {
        assert.deepEqualExcludingEvery([{ date: today }], [{ date: oldDay }], []);
    });
});

Upon further inspection, I noticed this :
In file chai-exclude.js, on ligne 203, this._obj value is [{ date: {} }]

But even then, how comes line 152 - new Assertion(actual, message).excludingEvery(props).to.deep.equal(expected) is validating this comparison ?

Is that the intended behavior ?

Node version is 20.15.1
Packages are :

"chai": "5.1.1",
"chai-exclude": "3.0.0",

Best regards,
Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant