-
Notifications
You must be signed in to change notification settings - Fork 255
Closed
Labels
accuracyImproves the accuracy of how behavior is simulatedImproves the accuracy of how behavior is simulatedenvironment:jsdomIssue with JSDOM environmentIssue with JSDOM environment
Milestone
Description
@testing-library/user-eventversion: 12.8.2
- Testing Framework and version: jest 26.6.0
- DOM Environment: jsdom 16.4.0
Relevant code or config
const handleChange = jest.fn();
render(<InputComponent changeHandler={handleChange} />);
const inputEl = screen.getByLabelText("Select file") as HTMLInputElement;
const file = new File([], "image.jpg");
userEvent.upload(inputEl, file);
await waitFor(() => expect(handleChange).toBeCalled());
inputEl.value = "";
userEvent.upload(inputEl, file);
//fails
await waitFor(() => expect(handleChange).toBeCalledTimes(2));What you did:
In #575, upload was changed so it correctly doesn't fire an onChange/onInput event when the same files are selected. In our use case, we do want it to fire again, and our workaround is adding an onClick event that sets inputEl.value = "".
What happened:
Second input event doesn't fire, even when the value is reset to blank.
Problem description:
Looking at the source, it doesn't appear to take value into account.
Suggested solution:
It should consider the value of the input field, but I'm not sure how the value relates to input.files, which is what is normally used.
Metadata
Metadata
Assignees
Labels
accuracyImproves the accuracy of how behavior is simulatedImproves the accuracy of how behavior is simulatedenvironment:jsdomIssue with JSDOM environmentIssue with JSDOM environment