Hey I have a jest related question. I am not sure how to count the number of keys in a json object.
I have this json response below and I want to ensure that there is only one event in the json object
<code> {
"data": {
"events": [
{
"id": "8370c670-58be-466a-8894-e841a33bef34",
"name": "England vs Switzerland",
}
]
}
}
</code>
<code> {
"data": {
"events": [
{
"id": "8370c670-58be-466a-8894-e841a33bef34",
"name": "England vs Switzerland",
}
]
}
}
</code>
{
"data": {
"events": [
{
"id": "8370c670-58be-466a-8894-e841a33bef34",
"name": "England vs Switzerland",
}
]
}
}
How do I do that? I tried
<code>expect(response.body.data.events.count).toBe(1);
</code>
<code>expect(response.body.data.events.count).toBe(1);
</code>
expect(response.body.data.events.count).toBe(1);
Looked at the jest documentation but nothing in there that makes it obviously to count the number of specific key in a response
1