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

Can't test "file" type inputs. #1203

Open
mveraldi-cisco opened this issue Mar 18, 2024 · 1 comment
Open

Can't test "file" type inputs. #1203

mveraldi-cisco opened this issue Mar 18, 2024 · 1 comment

Comments

@mveraldi-cisco
Copy link

Environment

  • @testing-library/react version: 14.2.1
  • Testing Framework and version:
    react-scripts version: 5.0.1
  • DOM Environment:
    jsdom from react-scripts

Reproduction:

Minimal reproduction on CodeSandbox: here

What you did:

I need to assert that my api is receiving the correct files. In this minimal reproduction it might not make sense because it's like I am testing DOM, but in my real world scenario the form is more complex and in that context this test makes sense.

What happened:

when I call
expect(api).toHaveBeenCalledWith({name: "hello.txt", file: file})
I receive {name: "", file: {}}.

Basically I am unable to assert what file was passed in the function.

Thank you.

@MatanBobi MatanBobi transferred this issue from testing-library/react-testing-library Mar 22, 2024
@MatanBobi
Copy link
Member

It looks like the input is getting the data (as can be seen in the reproduction, the input assertion is passing) but the Form itself isn't updated with that data.

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

No branches or pull requests

2 participants