Playwright · Junior · Question 36 of 75
How do you check that a list shows exactly 3 items?
- 1
await expect(items).toHaveCount(3) - 2
await expect(items).toHaveLength(3) - 3
expect(await items.length).toBe(3)
Show the answer
Correct answer: await expect(items).toHaveCount(3)
Explanation
toHaveCount retries until the number of matches is right, which handles lists that render gradually.