diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 32fd72f2e..42d88d273 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -966,16 +966,22 @@ module.exports = function (chai, _) { * ### .keys(key1, [key2], [...]) * * Asserts that the target contains any or all of the passed-in keys. - * When used in conjunction with `all`, every key that is passed in - * must exist in the target object. + * Use in combination with `any`, `all`, `contains`, or `have` will affect + * what will pass. * * When used in conjunction with `any`, at least one key that is passed - * in must exist in the target object. Use without the `any` or `all` - * qualifiers is deprecated and will default to `all`. + * in must exist in the target object. This is regardless whether or not + * the `have` or `contain` qualifiers are used. Note, either `any` or `all` + * should be used in the assertion. If neither are used, the assertion is + * defaulted to `all`. * - * Finally, use of the `all` qualifier in general requires that the number of - * keys passed in must match the number of keys in the target object unless - * the contains qualifier is also used. + * When both `all` and `contain` are used, the target object must have at + * least all of the passed-in keys but may have more keys not listed. + * + * When both `all` and `have` are used, the target object must both contain + * all of the passed-in keys AND the number of keys in the target object must + * match the number of keys passed in (in other words, a target object must + * have all and only all of the passed-in keys). * * expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz'); * expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');