-
Notifications
You must be signed in to change notification settings - Fork 468
Description
Hey @kentcdodds,
I'm totally enjoying using dom- and react-testing-library - thanks a lot!
Describe the feature you'd like:
We're using HTML description lists in our application:
<dl>
<dt>term1</dt>
<dd>value1</dd>
<dt>term2</dt>
<dd>value2</dd>
</dl>
I think it might be handy to select a dd
element by its dt
. In React for example, it could be used like this:
const { getByDescriptionTerm } = render(<MyDescriptionList />);
const dd = getByDescriptionTerm("term1");
Suggested implementation:
Tbh, I haven't yet looked into the internals of dom-testing-library. I suppose, it wouldn't be too different from other existing selectors. One thing that might be tricky though is that dt
doesn't necessarily contain a string but might also wrap other DOM elements.
Describe alternatives you've considered:
So far, I'm just asserting that all dt and dd elements exist and have the expected content. I haven't figured out a good way to match dt and dd elements to each other in my tests though.
I'm curious to hear what you think about the idea and its feasibility!
Best,
Nicolas