Mocking uppy with Jest

Started by goesbysteve1 reply556 views
goesbysteveOriginal post
#1

I’m trying to test a React component that uses uppy (core, XHRUpload & DragDrop) without much luck. My component imports and creates a new Uppy instance internally.

I want to just be able to assert on Uppy.setMeta or Uppy.upload being called however ideally I’d like to return a mocked response to an Uppy.on(‘complete’,()=>{}) handler.

Does anyone have a pattern this or some example code of successfully testing a similar situation please?

goesbysteve
#2

I ended up mocking the XHR which feels wrong but was the only thing I could get working in a reasonable amount of time.