Skip to content

feat: add toHaveCount and toBeEmpty assertions#122

Merged
gmegidish merged 1 commit into
mobile-next:mainfrom
alexC2K:feat/add-new-assertions
May 16, 2026
Merged

feat: add toHaveCount and toBeEmpty assertions#122
gmegidish merged 1 commit into
mobile-next:mainfrom
alexC2K:feat/add-new-assertions

Conversation

@alexC2K
Copy link
Copy Markdown
Contributor

@alexC2K alexC2K commented May 14, 2026

Summary

Adds two new locator assertions to LocatorAssertions in expect.ts, matching the Playwright API surface:

  • toHaveCount(n) - polls until the number of elements matched by a locator equals n.
  • toBeEmpty() - polls until a form element's value is an empty string.

Both assertions support .not negation and an optional { timeout } override, consistent with all other assertions in the file.
Also added unit tests for these two assertions.

Test plan

  • expect(locator).toHaveCount(3) passes when count matches
  • expect(locator).toHaveCount(5) throws ExpectError on mismatch (with short timeout)
  • expect(locator).not.toHaveCount(5) passes when count differs
  • expect(locator).toHaveCount(0) passes when nothing is found
  • expect(locator).toBeEmpty() passes when value is ""
  • expect(locator).toBeEmpty() throws when value is non-empty
  • expect(locator).not.toBeEmpty() passes when value is non-empty
  • All unit tests pass

@alexC2K alexC2K force-pushed the feat/add-new-assertions branch from 6d91d1a to 53eb762 Compare May 14, 2026 12:35
@gmegidish
Copy link
Copy Markdown
Member

@alexC2K thank you for this great addition! merging it in!

@gmegidish gmegidish merged commit 4bd1ab8 into mobile-next:main May 16, 2026
1 check 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