Constconst sym = Symbol('test');
const obj = {
  simple: 'value',
  'key.with.dots': 'direct property',
  'key[with]brackets': 'another direct property',
  [sym]: 'symbol value',
};
expect(obj, 'to have exact key', 'simple'); // passes
expect(obj, 'to have exact property', 'key.with.dots'); // passes (literal key)
expect(obj, 'to have exact prop', 'key[with]brackets'); // passes (literal key)
expect(obj, 'to have exact key', sym); // passes (symbol key)
// These would fail because they're not direct properties:
expect(obj, 'to have exact key', 'nested.path'); // fails (no keypath traversal)
Asserts that an object has an exact property key without keypath traversal. This assertion checks for direct properties on the object and supports symbols and keys that would conflict with bracket/dot notation.
Unlike
objectKeyAssertion, this does not use thehas()function and therefore: