jest-fetch-mock icon indicating copy to clipboard operation
jest-fetch-mock copied to clipboard

FormData is not defined

Open jhalborg opened this issue 7 years ago • 6 comments

Can't use the lib for testing FormData bodies it seems - getting FormData is not defined.

jhalborg avatar Jul 31 '17 09:07 jhalborg

Maybe inspiration can be found here https://github.com/RealOrangeOne/react-native-mock/blob/master/src/Libraries/Network/FormData.js

jhalborg avatar Jul 31 '17 09:07 jhalborg

@jhalborg do you mind sharing how you ended up testing FormData ?

MrHubble avatar Dec 04 '17 01:12 MrHubble

I never did, ended up skipping those tests, deadlines being deadlines. I posted a question on SO as well that received an answer recently, but haven't had time to test - maybe you are Marklar on SO? :-)

https://stackoverflow.com/q/45842088/1409779

jhalborg avatar Dec 04 '17 09:12 jhalborg

Thanks for taking the time to reply. Yep, that's me on SO. I'll continue the discussion on SO with the person who provided an answer.

MrHubble avatar Dec 04 '17 20:12 MrHubble

@MrHubble Did you ever figure out what was going wrong?

jefflau avatar Mar 21 '18 13:03 jefflau

@jefflau in the Stackoverflow question mentioned above I commented:

Adding global.FormData = ... before importing any other library did not work for me. What did end up working was:

jest.mock('react-native-aws3', () => { return { Request: { FormData: {} } } });. 

I'm not sure if this is the right thing to do as it appears I'll have to do it for a number of my dependencies

MrHubble avatar Mar 21 '18 21:03 MrHubble