<commit_before>Asserts the presence of a key.

Alias for [to be have keys](/assertions/object/to-have-keys).

```javascript
expect({ a: 'a', b: 'b', c: 'c' }, 'to have key', 'a');
```

Using the `only` flag you can assert that the object only have the
specified key.

```javascript
expect({ a: 'a' }, 'to only have key', 'a');
```

In case of a failing expectation you get the following output:

```javascript
expect({ a: 'a', b: 'b' }, 'to have key', 'c');
```

```output<commit_msg>Change alias to use relative url<commit_after>Asserts the presence of a key.

Alias for [to be have keys](../to-have-keys).

```javascript
expect({ a: 'a', b: 'b', c: 'c' }, 'to have key', 'a');
```

Using the `only` flag you can assert that the object only have the
specified key.

```javascript
expect({ a: 'a' }, 'to only have key', 'a');
```

In case of a failing expectation you get the following output:

```javascript
expect({ a: 'a', b: 'b' }, 'to have key', 'c');
```

```output
{'fraction_non_alphanumeric': 0.19155509783728114, 'fraction_numerical': 0.0, 'mean_word_length': 4.225806451612903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7050619', 'n_tokens_mistral': 341, 'n_tokens_neox': 324, 'n_words': 144}