Constconst obj = {
  foo: { bar: [{ baz: 'value' }] },
  'kebab-case': 'works',
};
expect(obj, 'to have key', 'foo.bar'); // passes
expect(obj, 'to have property', 'foo.bar[0].baz'); // passes
expect(obj, 'to have prop', 'foo["kebab-case"]'); // passes
expect(obj, 'to have key', 'nonexistent.path'); // fails
Asserts that an object has a property at the specified keypath using dot or bracket notation. Uses the
has()function to traverse nested properties and supports complex keypaths like 'foo.bar[0]["baz"]'.This assertion supports: