Skip to content

chai.assert.strictEqual should warn when comparing two undefined values #870

@mlee

Description

@mlee

Current behavior:

chai.assert.strictEqual(undefined, undefined) // -> passes

Desired behavior:

chai.assert.strictEqual(undefined, undefined) // -> passes with warning

If asserting on two undefined values, it is better to just use chai.assert.isUndefined. The problem with the current behavior is if the expected and actual arguments to strictEqual are undefined by mistake, the assertion will still pass.

A (contrived) example:

function testedFunc() {
  'asdf'; // desired behavior is actually to return 'asdf'
}

...

var expectedObj = {
  thing: 'asdf'
};

assert.strictEqual(testedFunc(), expectedObj.thin); // second argument should have been expectedObj.thing, but this assertion still passes

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