Closed msendlakowski closed 4 years ago
cc @delca85. I think this may be related to your changes. What do you think we should do here?
Yes, it is totally dued by my changes.
Like @msendlakowski said, the code looks for a label
with the id
found in the aria-labelledby
attribute in some element.
I think that the code flow should go on in a case like this, because this is maybe an incoherence found in the dom but not directly related to the inserted query and the element labeled by the desired value could still be found.
Maybe check if the element with the desired is is null
before calling getLabelContent
is what I should have done from the beginning.
If it sounds good to all of you I could work on it later today.
Sounds great!
:tada: This issue has been resolved in version 7.21.4 :tada:
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
@testing-library/dom
version: 7.21.2Relevant code or config:
What you did:
Identifying an icon
What happened:
Reproduction:
When the container does not have a node with id "c0-dialog-0-6-text"
Problem description:
This generates a JS error rather than returning a user friendly test failure. In fact, it should probably just fail the test with no error.
Suggested solution:
I think an appropriate fix would be just to return an empty string from the getLabelContent function when "label" doesn't exist. https://github.com/testing-library/dom-testing-library/blob/master/src/queries/label-text.js#L54