How to insert real File object to function in React unit tests

564 views Asked by At

I have a function that accepts File object as input parameter. Normally function gets it from form element, where user selects file.

Function converts input File to Image, manipulating it and then returns a blob. Conversion is done with image.src = URL.createObjectURL(file);, where file is input File object.

But how can I test that function with real files with jest? I need to read real image from local filesystem and pass it to that function. Any advice how to do that?

0

There are 0 answers