Skip to content

expect.eql() returns true when deeply comparing different Error objects #608

@MarcL

Description

@MarcL

I've run into an issue which I think is a bug when using deeply equals to compare two Error objects. Even though the message of the errors is different the expectation still returns that they're equal.

Here's an example using Mocha with expect().to.eql.

it('this test should fail', () => {
    const expectedError = new Error('An error');
    const error = new Error('A different error');
    expect(error).to.eql(expectedError);
});

Mocha passes this test even though I'd expect this to fail as the two errors have different message strings.

Is this a bug? I couldn't find any similar problems when searching the issues.

Thanks,
Marc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions