Skip to content

Instantly share code, notes, and snippets.

@claudiainbytes
Created February 11, 2026 19:01
Show Gist options
  • Select an option

  • Save claudiainbytes/ea03e314914ad674981bf77ecf303a94 to your computer and use it in GitHub Desktop.

Select an option

Save claudiainbytes/ea03e314914ad674981bf77ecf303a94 to your computer and use it in GitHub Desktop.
Testing File Upload
it('sube archivo', async () => {
const user = userEvent.setup()
const handleUpload = vi.fn()
render(<FileUpload onUpload={handleUpload} />)
const file = new File(['hello'], 'hello.png', { type: 'image/png' })
const input = screen.getByLabelText(/upload/i)
await user.upload(input, file)
expect(handleUpload).toHaveBeenCalledWith(
expect.objectContaining({
name: 'hello.png',
type: 'image/png',
})
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment