- Notifications
You must be signed in to change notification settings - Fork 255
Description
Reproduction example
https://codesandbox.io/s/white-wood-jnes8g
Prerequisites
A user can select a file that does not match the accept type of the input element. We (as programmers) are expected to handle this flow in our code and thus should be able to test this flow with unit tests. However, currently it is impossible to select a file that that does not match the accept type with userEvent.upload() helper - the selection is being silently ignored.
- Click on "Choose File"
- In the dialog, toggle file type selector from "*.json" to "all files"
- Select a non-JSON file
- Observe filename as it appears in the output field
Unfortunately, steps 2 and 3 were not captured on the video below, but you can observe the result.
white-wood-jnes8g.-.CodeSandbox.-.Google.Chrome.2022-08-25.14-59-57.mp4
Expected behavior
I expect the unit test in the reproduction example to pass.
Actual behavior
The unit test fails.
As a result, we cannot unit-test a flow where user selects an invalid file.
User-event version
14.4.3
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response