Skip to content
New issue

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

Allow configurable data-testid attribute on file input #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emilong
Copy link

@emilong emilong commented May 12, 2023

Automated test runners such as Cypress cannot interact with system dialogs such as the file selection dialog box. In order to allow testing this module, this change does two things:

  1. It does not remove the input from the DOM until the file has changed. Previously it was removed on the next animation frame, but now it's removed in the onchange handler. For actual human interaction, this change should behave equivalently, but for test runners it gives them a chance to find and upload a file to the file input.
  2. There is a configurable data-testid attribute for the file input. This data attribute is a common one for test frameworks and allows them to find the input easily.

Automated test runners such as Cypress cannot interact with system
dialogs such as the file selection dialog box. In order to allow testing
this module, this change does two things:

1. It does not remove the input from the DOM until the file has changed.
   Previously it was removed on the next animation frame, but now it's
   removed in the onchange handler. For actual human interaction, this
   change should behave equivalently, but for test runners it gives them
   a chance to find and upload a file to the file input.
2. There is a configurable `data-testid` attribute for the file input.
   This data attribute is a common one for test frameworks and allows
   them to find the input easily.
@emilong emilong marked this pull request as ready for review May 12, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant