-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Add toHaveCount
, assertion for count of elements
#30
Comments
Sounds useful! |
I have a chat app and such an assertion would be very helpful |
Should be released in new version. @mxschmitt could you please publish new one. I just don't have access to do it |
Published 0.3.0 👍 |
I didn't see the above request implemented here: https://playwright.dev/docs/test-assertions#locator-assertions-to-have-count await expect(this.questions).toHaveCount(1) I want to validate if my list count is greater than 1. |
@tarun1122 Not sure, but this might work: await expect(this.questions).not.toHaveCount(0)
await expect(this.questions).not.toHaveCount(1) As a side note, your question should probably be opened as an issue in the Playwright repo. |
@mskelton Actually my list is dynamic. Sometimes it gives 2 questions sometimes 5+. I just need to ensure that my list always has atleast 1 question and hence, I want to check the list count is greater than 1. |
Right, if you verify the count is not 0 and not 1, that then ensures there is at least two elements. |
I have the same problem... I would like to write a test for a dynamic list, so sometimes my list has 5 elements, or more than 20... is there a way to test this? |
@douglaslb, you might want to use await expect(await questions.count()).toBeGreaterThan(20); |
I need new assertion checking the count of elements which the selector matches.
It's very useful to verify the count of elements.
It might be better to consider if the new assertion can verify the greater or less count.
The text was updated successfully, but these errors were encountered: