Skip to content

expect return value can't be reused with .to.have.property. #81

@anko

Description

@anko

Here's a minimal illustration in Mocha:

var expect = require("expect.js");
describe("", function() {
    specify("", function() {

        var y = expect({ a : 1, b : 2 });
        y.to.have.property("a", 1);         // This is OK.
        y.to.have.property("b", 2);         // Mocha outputs "Error: expected 1
                                            // to have a property 'b'".

    });
});

I'm reusing expect's return value. Why is expect.js expecting 1 to have a property b?

The issue seems to be with .to.have.property, as using other assertions works fine:

        var x = expect(1);
        x.to.be.equal(1);                   // This is OK.
        x.to.not.be.equal(0);               // This is OK too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions