Skip to content

Add assertCount() method #1158

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

Merged
merged 3 commits into from
Feb 5, 2025
Merged

Add assertCount() method #1158

merged 3 commits into from
Feb 5, 2025

Conversation

ktsm-th
Copy link
Contributor

@ktsm-th ktsm-th commented Jan 31, 2025

This PR adds a new helper to assert the number of matching elements on the page.

It's useful when assertions are performed on DOM elements that are tied to factories:

Books::factory()
    ->times(3)
    ->sequence(['stock' => true], ['stock' => true], ['stock' => false])
    ->create();

$browser->assertCount('input[name="books_in_stock"]:checked', 2);

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@ktsm-th ktsm-th marked this pull request as ready for review January 31, 2025 16:41
@taylorotwell taylorotwell merged commit f0e6870 into laravel:8.x Feb 5, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants