userEvent.upload() files attribute is only a getter v14 #1155
Unanswered
borja-sanz-sanz
asked this question in
Q&A
Replies: 1 comment
-
Hello ! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everyone,
I've been digging into the changes in version 14, particularly focusing on userEvent.upload. One of the significant changes I've noticed is how it handles the files attribute of the HTMLInputElement.
You could read and write the files attribute directly in previous versions. However, in the latest version, this attribute has been transformed into a getter property, meaning you can only retrieve its value, but you can't assign new values to it.
This change has caught my attention because it deviates from the usual behavior of the HTMLInputElement. Normally, you can directly set the files property to upload files or manipulate them as needed. The problem with this new approach is that it may lead to issues in testing scenarios. Imagine a situation where someone is modifying the files attribute directly, the test will not work.
To address this potential source of confusion and make userEvent.upload more user-friendly, I propose adding a setter method for the files attribute. This would align the behavior of userEvent.upload with the standard behavior of HTMLInputElement. Developers and testers would then have a more consistent and intuitive experience when working with this library.
I've found this issue because I need to modify the files attribute directly, It's working correctly but when I try to test that the userEvent.upload() method is rewriting my actual input and throws an error saying that I cannot modify only getter property. This was not happening on v13.
I'm talking of this part of code in src/utils/edit/setFiles.ts file
I'm eager to hear your thoughts on this proposal and whether it could be a beneficial addition to the library.
Thanks for your input!
Beta Was this translation helpful? Give feedback.
All reactions