-
Notifications
You must be signed in to change notification settings - Fork 406
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
toBeInTheDOM name is misleading about what it really does #3
Comments
I'm in favor of all three of these matchers, especially these two: expect(container).toContainElement(element)
expect(element).toBeInTheDOM(container) 👍 |
But |
Yes, it would be optional 👍 |
Ok, I should have time to work on some of these later this week, but if someone else can give it a crack, go for it. (Maybe @sompylasar, since he originally reported it and was needing it?) |
BTW, I'd rule this out for the time being: expect(element).toBeAChildOf(parent) As its name suggest, it'd be checking only for a direct parent-child relationship between two nodes. This is not as useful and it's a bit more brittle than checking a more general ancestry relationship. After all, users on the screen do not really know about direct relationships. They generally care about seeing some elements inside others, and that's what |
@gnapse I can give it a shot on this, if I get some time tomorrow. |
@antoaravinth are you still up to get this? |
@gnapse Sorry was busy.. Yeah should be able to close this when I get time :) |
Sure, no problem and no hurries, just wanted to check if your offer was still on. |
* #3: Moved tests to their own files for easier viewing. * #3: Added to-contain-element * #3: Updated to-be-in-the-dom to have container element check * #3: Updated types to match functions * #3: Updated documentation for toContainElement and toBeInTheDOM * #3: Added user to contributors * #3: Updated to-contain-element for better code coverage * #3: Reverted tests back to one file * Set container to be optional in types (toBeInTheDOM)
Closing as this was solved in #25 |
As reported by @sompylasar in testing-library/dom-testing-library#9
.toBeInTheDOM
is not really checking for what it name implies (because it does not have the concept of what "the DOM" is to being with). Right now is just a glorified.toBeInstanceOfClass(HTMLElement)
.Refer to the original discussion for all suggested solutions. I'll mention here a few from there plus a new one:
The text was updated successfully, but these errors were encountered: