Closed s100 closed 1 month ago
Actually, after hacking @testing-library/user-event
to bypass isUIValue
, I see a different error, this one from JSDOM:
InvalidStateError: This input element accepts a filename, which may only be programmatically set to the empty string.
I think this indicates that this isn't an issue with @testing-library/user-event
but in <FileUploaderDropContainer>
.
Package
@carbon/react
Browser
Edge
Package version
1.65.0
React version
18.3.1
Description
During unit testing involving
<FileUploaderDropContainer>
using@testing-library/user-event
, we see the following error:The cause of this is this code where we are setting
evt.target.value = null
.The actual error comes from
@testing-library/user-event
here where they are seemingly failing to account for the possibility of thevalue
property of anHTMLInputElement
beingnull
. However, in actuality, thevalue
property of an<input type='file'>
can't benull
. It's always a string. As far as I can tell, the types check out. The fact that it's possible to manually set it tonull
is an artifact of testing. In reality, setting the value tonull
sets it to the empty string,''
.My recommendation is that Carbon's code should be changed to
evt.target.value = ''
.Reproduction/example
https://stackblitz.com/edit/github-6ae745?file=src%2FApp.jsx
Steps to reproduce
This isn't a bug I can reproduce in a web browser, it only appears during Jest testing:
Suggested Severity
None
Application/PAL
IBM App Connect Enterprise (don't know what a PAL is)
Code of Conduct