We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Could someone explain to me the logic behind this line of code: https://github.com/testing-library/user-event/blob/master/src/upload.js#L17 ?
Consider this code snippet:
function handleChooseImage(event: ChangeEvent<HTMLInputElement>) { const selectedFiles = event.target.files if (!selectedFiles?.length) return ... } <input data-testid="add-photos-input" ref={inputRef} type="file" onChange={handleChooseImage} accept="image/*" multiple hidden />
My goal is to write following lines of test code
const imageFile = new File([], 'imgname', { type: 'image/png' }) const imageInput = screen.getByTestId('add-photos-input') userEvent.upload(imageInput, imageFile)
This test code result in event handler being called with an object, where length is undefined and item() returns undefined:
length
undefined
item()
selectedFiles: { length: undefined, item: [Function: item] }
Is that expected behaviour?
The text was updated successfully, but these errors were encountered:
The function expects you to provide File for single file inputs and File[] for multiple file inputs.
File
File[]
userEvent.upload(multipleFileInput, [imageFile])
I think this could be improved by just converting it.
Sorry, something went wrong.
fix(upload): accept File or File[] #529
f645798
fix(upload): accept File or File[] #529 (#530)
390013e
resolved in 12.6.2
No branches or pull requests
Could someone explain to me the logic behind this line of code: https://github.com/testing-library/user-event/blob/master/src/upload.js#L17 ?
Consider this code snippet:
My goal is to write following lines of test code
This test code result in event handler being called with an object, where
length
isundefined
anditem()
returnsundefined
:selectedFiles: { length: undefined, item: [Function: item] }
Is that expected behaviour?
The text was updated successfully, but these errors were encountered: