Replies: 1 comment
-
This looks like something that you should be asking about in jsdom. It's not related to jest-dom, is it? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using mock-service-worker
to mock this function that downloads image
getImage()
is then called in react-hook-form to load image asynchronously into the form via Dropzonethen Dropzone displays that image using
URL.createObjectURL()
then inside the test file I asert that img tag has
src
attribute in formatblob:https://site.com/uplads/headers/image.jpg
mock-service-worker mock works fine and returns binary data, main problem is in File constructor which in jsdom always returns just empty object
{}
, this lineconst file = new File([response.data], 'default-image');
, so I need to mock it in global namespace, but I cant find single example on Google how to do it.I also plan to mock
URL.createObjectURL
just to forward image url to the src attribute.Jest environment is:
Do you know where I can find complete type safe example how to mock
File
constructor in jsdom?Beta Was this translation helpful? Give feedback.
All reactions