hapijs / code

Assertion library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaking change in include assertion in Code 4.0.0?

blacksun1 opened this issue · comments

Hi,

the following code works in Code 3.0.2 and failed in 4.0.0

"use strict"

const Code = require("code");

const test = {
    "z": {
        "a": "foo",
        "b": "bar",
        "c": "baz"
    }
};

try {
    Code.expect(test).to.include({
        "z": {
            "a": "foo",
            "b": "bar"
        }
    });
    console.log("All good");
} catch(err) {
    console.log("Failed", err);
}

Error output on Code 4.0.0 was

Error: Expected { statusCode: 400, result: { error: 'Bad Request', message: 'Something was wrong', cake: 'chocolate' } } to include { statusCode: 400, result: { error: 'Bad Request', message: 'Something was wrong' } }

Is this is an expected breaking change?

Yes. Please see the discussion in #77. Basically, the only breaking change in v4.0.0 was the handling of the include() method's part flag.

Thanks for headsup.

commented

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.