Skip to content
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: implement toBeEmptyElement Jest matcher #1459

Closed
mdjastrzebski opened this issue Aug 17, 2023 · 3 comments · Fixed by #1462
Closed

feature: implement toBeEmptyElement Jest matcher #1459

mdjastrzebski opened this issue Aug 17, 2023 · 3 comments · Fixed by #1462
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mdjastrzebski
Copy link
Member

Describe the Feature

toBeEmptyDOMElement is a Jest DOM matcher that asserts the visibility of given element by inspecting whether it contains any child elements.

Adapting it to our case it would assert that given host element does not contain any host children elements. It might contain some composite elements as long as these do not have host descendants. We already have function for getting host children of given element (getHostChildren) so that should be relatively straightforward.

Possible Implementations

Proposed API:

export function toBeEmptyElement(
  this: jest.MatcherContext,
  element: ReactTestInstance
)

The matcher should:

  1. Validate that it is invoked on a host element
  2. Check if given element contains any host child elements (using getHostChildren fn)

Each matcher should have a fairly comprehensive test suite.

Links

Related Issues

#1454

@mdjastrzebski mdjastrzebski added help wanted Extra attention is needed good first issue Good for newcomers labels Aug 17, 2023
@kyawthura-gg
Copy link
Contributor

Hi @mdjastrzebski, I would like to work on this issue. Thanks

@mdjastrzebski
Copy link
Member Author

@kyawthura-gg Go ahead! Pls submit PR when you're ready.

@mdjastrzebski
Copy link
Member Author

🎉 Release in version: v12.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants